Java Code Examples for com.csvreader.CsvReader#setTrimWhitespace()

The following examples show how to use com.csvreader.CsvReader#setTrimWhitespace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CSPARQLAarhusTrafficStream.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
public CSPARQLAarhusTrafficStream(String uri, String txtFile, EventDeclaration ed, Date start, Date end)
		throws IOException {
	super(uri);
	logger.info("IRI: " + this.getIRI().split("#")[1] + ed.getInternalQos());
	this.startDate = start;
	this.endDate = end;
	messageCnt = 0;
	byteCnt = 0;
	this.txtFile = txtFile;
	this.ed = ed;
	streamData = new CsvReader(String.valueOf(txtFile));
	streamData.setTrimWhitespace(false);
	streamData.setDelimiter(',');
	streamData.readHeaders();
	metaData = new CsvReader("dataset/MetaData/trafficMetaData.csv");
	metaData.readHeaders();
	streamData.readRecord();
	while (metaData.readRecord()) {
		if (streamData.get("REPORT_ID").equals(metaData.get("REPORT_ID"))) {
			// p1Street = metaData.get("POINT_1_STREET");
			// p1City = metaData.get("POINT_1_CITY");
			// p1Lat = metaData.get("POINT_1_LAT");
			// p1Lon = metaData.get("POINT_1_LNG");
			// p1Country = metaData.get("POINT_2_COUNTRY");
			// p2Street = metaData.get("POINT_2_STREET");
			// p2City = metaData.get("POINT_2_CITY");
			// p2Lat = metaData.get("POINT_2_LAT");
			// p2Lon = metaData.get("POINT_2_LNG");
			// p2Country = metaData.get("POINT_2_COUNTRY");
			distance = metaData.get("DISTANCE_IN_METERS");
			if (ed instanceof TrafficReportService)
				((TrafficReportService) ed).setDistance(Integer.parseInt(distance));

			// timestamp = metaData.get("TIMESTAMP");
			// id = metaData.get("extID");
			metaData.close();
			break;
		}
	}
}
 
Example 2
Source File: CQELSAarhusWeatherStream.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
public CQELSAarhusWeatherStream(ExecContext context, String uri, String txtFile, EventDeclaration ed, Date start,
		Date end) throws IOException {
	super(context, uri);
	streamData = new CsvReader(String.valueOf(txtFile));
	this.ed = ed;
	streamData.setTrimWhitespace(false);
	streamData.setDelimiter(',');
	streamData.readHeaders();
	this.startDate = start;
	this.endDate = end;
}
 
Example 3
Source File: CQELSAarhusWeatherStream.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
public CQELSAarhusWeatherStream(ExecContext context, String uri, String txtFile, EventDeclaration ed)
		throws IOException {
	super(context, uri);
	streamData = new CsvReader(String.valueOf(txtFile));
	this.ed = ed;
	streamData.setTrimWhitespace(false);
	streamData.setDelimiter(',');
	streamData.readHeaders();
}
 
Example 4
Source File: CQELSAarhusPollutionStream.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
public CQELSAarhusPollutionStream(ExecContext context, String uri, String txtFile, EventDeclaration ed, Date start,
		Date end) throws IOException {
	super(context, uri);

	streamData = new CsvReader(String.valueOf(txtFile));
	this.ed = ed;
	streamData.setTrimWhitespace(false);
	streamData.setDelimiter(',');
	streamData.readHeaders();
	this.startDate = start;
	this.endDate = end;
}
 
Example 5
Source File: CQELSAarhusPollutionStream.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
public CQELSAarhusPollutionStream(ExecContext context, String uri, String txtFile, EventDeclaration ed)
		throws IOException {
	super(context, uri);
	streamData = new CsvReader(String.valueOf(txtFile));
	this.ed = ed;
	streamData.setTrimWhitespace(false);
	streamData.setDelimiter(',');
	streamData.readHeaders();
}
 
Example 6
Source File: CQELSAarhusParkingStream.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
public CQELSAarhusParkingStream(ExecContext context, String uri, String txtFile, EventDeclaration ed, Date start,
		Date end) throws IOException {
	super(context, uri);

	streamData = new CsvReader(String.valueOf(txtFile));
	this.ed = ed;
	streamData.setTrimWhitespace(false);
	streamData.setDelimiter(',');
	streamData.readHeaders();
	this.startDate = start;
	this.endDate = end;
}
 
Example 7
Source File: CQELSAarhusParkingStream.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
public CQELSAarhusParkingStream(ExecContext context, String uri, String txtFile, EventDeclaration ed)
		throws IOException {
	super(context, uri);
	streamData = new CsvReader(String.valueOf(txtFile));
	this.ed = ed;
	streamData.setTrimWhitespace(false);
	streamData.setDelimiter(',');
	streamData.readHeaders();
}
 
Example 8
Source File: CQELSAarhusTrafficStream.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
public CQELSAarhusTrafficStream(ExecContext context, String uri, String txtFile, EventDeclaration ed, Date start,
		Date end) throws IOException {
	super(context, uri);
	this.startDate = start;
	this.endDate = end;
	messageCnt = 0;
	byteCnt = 0;
	this.txtFile = txtFile;
	this.ed = ed;
	streamData = new CsvReader(String.valueOf(txtFile));
	streamData.setTrimWhitespace(false);
	streamData.setDelimiter(',');
	streamData.readHeaders();
	metaData = new CsvReader("dataset/MetaData/trafficMetaData.csv");
	metaData.readHeaders();
	streamData.readRecord();
	while (metaData.readRecord()) {
		if (streamData.get("REPORT_ID").equals(metaData.get("REPORT_ID"))) {
			// p1Street = metaData.get("POINT_1_STREET");
			// p1City = metaData.get("POINT_1_CITY");
			// p1Lat = metaData.get("POINT_1_LAT");
			// p1Lon = metaData.get("POINT_1_LNG");
			// p1Country = metaData.get("POINT_2_COUNTRY");
			// p2Street = metaData.get("POINT_2_STREET");
			// p2City = metaData.get("POINT_2_CITY");
			// p2Lat = metaData.get("POINT_2_LAT");
			// p2Lon = metaData.get("POINT_2_LNG");
			// p2Country = metaData.get("POINT_2_COUNTRY");
			distance = metaData.get("DISTANCE_IN_METERS");
			// timestamp = metaData.get("TIMESTAMP");
			// id = metaData.get("extID");
			metaData.close();
			break;
		}
	}
}
 
Example 9
Source File: CSVMatrixReader.java    From sailfish-core with Apache License 2.0 5 votes vote down vote up
public CSVMatrixReader(InputStream inputStream, char delimiter, String encoding) throws IOException {

        Reader rdr = new UnicodeReader(inputStream, encoding);

        reader = new CsvReader(rdr);
        reader.setDelimiter(delimiter);
        reader.setSkipEmptyRecords(false);
        reader.setTrimWhitespace(true);
        readRecord();
    }
 
Example 10
Source File: CSPARQLAarhusPollutionStream.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
public CSPARQLAarhusPollutionStream(String uri, String txtFile, EventDeclaration ed, Date start, Date end)
		throws IOException {
	super(uri);

	streamData = new CsvReader(String.valueOf(txtFile));
	this.ed = ed;
	streamData.setTrimWhitespace(false);
	streamData.setDelimiter(',');
	streamData.readHeaders();
	this.startDate = start;
	this.endDate = end;
}
 
Example 11
Source File: CSPARQLAarhusPollutionStream.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
public CSPARQLAarhusPollutionStream(String uri, String txtFile, EventDeclaration ed) throws IOException {
	super(uri);
	streamData = new CsvReader(String.valueOf(txtFile));
	this.ed = ed;
	streamData.setTrimWhitespace(false);
	streamData.setDelimiter(',');
	streamData.readHeaders();
}
 
Example 12
Source File: CSPARQLAarhusParkingStream.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
public CSPARQLAarhusParkingStream(String uri, String txtFile, EventDeclaration ed, Date start, Date end)
		throws IOException {
	super(uri);
	logger.info("init");
	streamData = new CsvReader(String.valueOf(txtFile));
	this.ed = ed;
	streamData.setTrimWhitespace(false);
	streamData.setDelimiter(',');
	streamData.readHeaders();
	this.startDate = start;
	this.endDate = end;
}
 
Example 13
Source File: CSPARQLAarhusParkingStream.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
public CSPARQLAarhusParkingStream(String uri, String txtFile, EventDeclaration ed) throws IOException {
	super(uri);
	streamData = new CsvReader(String.valueOf(txtFile));
	this.ed = ed;
	streamData.setTrimWhitespace(false);
	streamData.setDelimiter(',');
	streamData.readHeaders();
}
 
Example 14
Source File: CSPARQLAarhusWeatherStream.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
public CSPARQLAarhusWeatherStream(String uri, String txtFile, EventDeclaration ed, Date start, Date end)
		throws IOException {
	super(uri);
	streamData = new CsvReader(String.valueOf(txtFile));
	this.ed = ed;
	streamData.setTrimWhitespace(false);
	streamData.setDelimiter(',');
	streamData.readHeaders();
	this.startDate = start;
	this.endDate = end;
}
 
Example 15
Source File: CSPARQLAarhusWeatherStream.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
public CSPARQLAarhusWeatherStream(String uri, String txtFile, EventDeclaration ed) throws IOException {
	super(uri);
	streamData = new CsvReader(String.valueOf(txtFile));
	this.ed = ed;
	streamData.setTrimWhitespace(false);
	streamData.setDelimiter(',');
	streamData.readHeaders();
}
 
Example 16
Source File: CSPARQLAarhusTrafficStream.java    From Benchmark with GNU General Public License v3.0 4 votes vote down vote up
public CSPARQLAarhusTrafficStream(String uri, String txtFile, EventDeclaration ed) throws IOException {
	super(uri);
	String fileName = "";
	if (this.getIRI().split("#").length > 1)
		fileName = this.getIRI().split("#")[1];
	else
		fileName = this.getIRI();
	// logFile = new File("resultlog/" + fileName + ".csv");
	// fw = new FileWriter(logFile);
	// cw = new CsvWriter(fw, ',');
	// cw.write("time");
	// cw.write("message_cnt");
	// cw.write("byte_cnt");
	// cw.endRecord();heh
	// cw.flush();
	messageCnt = 0;
	byteCnt = 0;
	this.txtFile = txtFile;
	this.ed = ed;
	// time1 = time.getTime();
	streamData = new CsvReader(String.valueOf(txtFile));
	streamData.setTrimWhitespace(false);
	streamData.setDelimiter(',');
	streamData.readHeaders();
	// streamData.skipRecord();
	metaData = new CsvReader("dataset/MetaData/trafficMetaData.csv");
	metaData.readHeaders();
	streamData.readRecord();
	while (metaData.readRecord()) {
		if (streamData.get("REPORT_ID").equals(metaData.get("REPORT_ID"))) {
			// p1Street = metaData.get("POINT_1_STREET");
			// p1City = metaData.get("POINT_1_CITY");
			// p1Lat = metaData.get("POINT_1_LAT");
			// p1Lon = metaData.get("POINT_1_LNG");
			// p1Country = metaData.get("POINT_2_COUNTRY");
			// p2Street = metaData.get("POINT_2_STREET");
			// p2City = metaData.get("POINT_2_CITY");
			// p2Lat = metaData.get("POINT_2_LAT");
			// p2Lon = metaData.get("POINT_2_LNG");
			// p2Country = metaData.get("POINT_2_COUNTRY");
			distance = metaData.get("DISTANCE_IN_METERS");
			if (ed instanceof TrafficReportService)
				((TrafficReportService) ed).setDistance(Integer.parseInt(distance));

			// timestamp = metaData.get("TIMESTAMP");
			// id = metaData.get("extID");
			// stream(n(RDFFileManager.defaultPrefix + streamData.get("REPORT_ID")),
			// n(RDFFileManager.ctPrefix + "hasETA"), n(data.getEstimatedTime() + ""));
			// System.out.println("metadata: " + metaData.toString());
			metaData.close();
			break;
		}
	}
}
 
Example 17
Source File: CQELSAarhusTrafficStream.java    From Benchmark with GNU General Public License v3.0 4 votes vote down vote up
public CQELSAarhusTrafficStream(ExecContext context, String uri, String txtFile, EventDeclaration ed)
		throws IOException {
	super(context, uri);
	String fileName = "";
	if (this.getURI().split("#").length > 1)
		fileName = this.getURI().split("#")[1];
	else
		fileName = this.getURI();
	// logFile = new File("resultlog/" + fileName + ".csv");
	// fw = new FileWriter(logFile);
	// cw = new CsvWriter(fw, ',');
	// cw.write("time");
	// cw.write("message_cnt");
	// cw.write("byte_cnt");
	// cw.endRecord();
	// cw.flush();
	messageCnt = 0;
	byteCnt = 0;
	this.txtFile = txtFile;
	this.ed = ed;
	// time1 = time.getTime();
	streamData = new CsvReader(String.valueOf(txtFile));
	streamData.setTrimWhitespace(false);
	streamData.setDelimiter(',');
	streamData.readHeaders();
	// streamData.skipRecord();
	metaData = new CsvReader("dataset/MetaData/trafficMetaData.csv");
	metaData.readHeaders();
	streamData.readRecord();
	while (metaData.readRecord()) {
		if (streamData.get("REPORT_ID").equals(metaData.get("REPORT_ID"))) {
			// p1Street = metaData.get("POINT_1_STREET");
			// p1City = metaData.get("POINT_1_CITY");
			// p1Lat = metaData.get("POINT_1_LAT");
			// p1Lon = metaData.get("POINT_1_LNG");
			// p1Country = metaData.get("POINT_2_COUNTRY");
			// p2Street = metaData.get("POINT_2_STREET");
			// p2City = metaData.get("POINT_2_CITY");
			// p2Lat = metaData.get("POINT_2_LAT");
			// p2Lon = metaData.get("POINT_2_LNG");
			// p2Country = metaData.get("POINT_2_COUNTRY");
			distance = metaData.get("DISTANCE_IN_METERS");
			// timestamp = metaData.get("TIMESTAMP");
			// id = metaData.get("extID");
			// stream(n(RDFFileManager.defaultPrefix + streamData.get("REPORT_ID")),
			// n(RDFFileManager.ctPrefix + "hasETA"), n(data.getEstimatedTime() + ""));
			// System.out.println("metadata: " + metaData.toString());
			metaData.close();
			break;
		}
	}
}
 
Example 18
Source File: FileOperation.java    From Benchmark with GNU General Public License v3.0 4 votes vote down vote up
public static void main(String[] args) throws IOException {
	// File trafficRawDirectory = new File("streams");
	// File[] trafficRawFiles = trafficRawDirectory.listFiles();
	// for (File tr : trafficRawFiles) {
	// System.out.println("renaming: " + tr.toPath());
	// File newTr;
	// if (tr.getName().contains("traffic")) {
	// newTr = new File("streams" + File.separator + "AarhusT"
	// + tr.getName().substring(1, tr.getName().length()));
	// tr.renameTo(newTr);
	// } else if (tr.getName().contains("pollution")) {
	// newTr = new File("streams" + File.separator + "AarhusP"
	// + tr.getName().substring(1, tr.getName().length()));
	// tr.renameTo(newTr);
	// }
	//
	// // Files.copy(tr.toPath(), newTr.toPath());
	// }
	CsvReader streamData = new CsvReader("dataset/aarhus_parking.csv");
	streamData.setTrimWhitespace(false);
	streamData.setDelimiter(',');
	streamData.readHeaders();

	List<String> streamNames = new ArrayList<String>();
	streamNames.add("NORREPORT");
	streamNames.add("BUSGADEHUSET");
	streamNames.add("BRUUNS");
	streamNames.add("SKOLEBAKKEN");
	streamNames.add("SCANDCENTER");
	streamNames.add("SALLING");
	streamNames.add("MAGASIN");
	streamNames.add("KALKVAERKSVEJ");

	Map<String, CsvWriter> writerMap = new HashMap<String, CsvWriter>();
	for (String s : streamNames)
		try {
			// use FileWriter constructor that specifies open for appending
			String outputFile = "dataset/AarhusParkingData-" + s + ".stream";
			boolean alreadyExists = new File(outputFile).exists();
			CsvWriter csvOutput = new CsvWriter(new FileWriter(outputFile, true), ',');

			// if the file didn't already exist then we need to write out the header line
			if (!alreadyExists) {
				csvOutput.write("vehiclecount");
				csvOutput.write("updatetime");
				csvOutput.write("_id");
				csvOutput.write("totalspaces");
				csvOutput.write("garagecode");
				csvOutput.write("streamtime");
				csvOutput.endRecord();
			}
			// }
			writerMap.put(s, csvOutput);
			// csvOutput.close();
		} catch (IOException e) {
			e.printStackTrace();
		}

	while (streamData.readRecord()) {
		String code = streamData.get("garagecode");
		writerMap.get(code).write(streamData.get("vehiclecount"));
		writerMap.get(code).write(streamData.get("updatetime"));
		writerMap.get(code).write(streamData.get("_id"));
		writerMap.get(code).write(streamData.get("totalspaces"));
		writerMap.get(code).write(streamData.get("garagecode"));
		writerMap.get(code).write(streamData.get("streamtime"));
		writerMap.get(code).endRecord();
	}
	for (CsvWriter csv : writerMap.values())
		csv.close();
}