Java Code Examples for com.csvreader.CsvReader#readHeaders()
The following examples show how to use
com.csvreader.CsvReader#readHeaders() .
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: CSPARQLAarhusPollutionStream.java From Benchmark with GNU General Public License v3.0 | 5 votes |
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 2
Source File: CQELSAarhusPollutionStream.java From Benchmark with GNU General Public License v3.0 | 5 votes |
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 3
Source File: ReadDocument.java From Benchmark with GNU General Public License v3.0 | 5 votes |
public static AarhusTrafficObservation getStreamData(String dataFile) throws NumberFormatException, IOException { CsvReader streamData = new CsvReader(String.valueOf(dataFile)); streamData.readHeaders(); // Reads csv document for traffic metadata try { CsvReader metaData = new CsvReader("dataset/MetaData/trafficMetaData.csv"); metaData.readHeaders(); AarhusTrafficObservation data = new AarhusTrafficObservation(); while (streamData.readRecord()) { while (metaData.readRecord()) { if (streamData.get("REPORT_ID").equals(metaData.get("REPORT_ID"))) { data = new AarhusTrafficObservation(Double.parseDouble(streamData.get("REPORT_ID")), Double.parseDouble(streamData.get("avgSpeed")), Double.parseDouble(streamData .get("vehicleCount")), Double.parseDouble(streamData.get("avgMeasuredTime")), 0, 0, metaData.get("POINT_1_STREET"), metaData.get("POINT_1_CITY"), Double.parseDouble(metaData.get("POINT_1_LAT")), Double.parseDouble(metaData .get("POINT_1_LNG")), metaData.get("POINT_2_STREET"), metaData.get("POINT_2_CITY"), Double.parseDouble(metaData.get("POINT_2_LAT")), Double.parseDouble(metaData.get("POINT_2_LNG")), metaData.get("POINT_1_COUNTRY"), metaData.get("POINT_2_COUNTRY"), metaData.get("TIMESTAMP")); Double distance = Double.parseDouble(metaData.get("DISTANCE_IN_METERS")); data.setEstimatedTime(distance / data.getAverageSpeed()); data.setCongestionLevel(data.getVehicle_count() / distance); } } } streamData.close(); metaData.close(); return data; } catch (Exception e) { e.printStackTrace(); } return null; }
Example 4
Source File: CQELSAarhusParkingStream.java From Benchmark with GNU General Public License v3.0 | 5 votes |
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 5
Source File: CQELSAarhusParkingStream.java From Benchmark with GNU General Public License v3.0 | 5 votes |
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 6
Source File: CQELSAarhusTrafficStream.java From Benchmark with GNU General Public License v3.0 | 5 votes |
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 7
Source File: CQELSAarhusWeatherStream.java From Benchmark with GNU General Public License v3.0 | 5 votes |
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 8
Source File: CQELSAarhusWeatherStream.java From Benchmark with GNU General Public License v3.0 | 5 votes |
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 9
Source File: CSPARQLAarhusParkingStream.java From Benchmark with GNU General Public License v3.0 | 5 votes |
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 10
Source File: CSPARQLAarhusParkingStream.java From Benchmark with GNU General Public License v3.0 | 5 votes |
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 11
Source File: CSPARQLAarhusWeatherStream.java From Benchmark with GNU General Public License v3.0 | 5 votes |
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 12
Source File: CSPARQLAarhusWeatherStream.java From Benchmark with GNU General Public License v3.0 | 5 votes |
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 13
Source File: Utils.java From ipst with Mozilla Public License 2.0 | 5 votes |
public static List readHistoDataFromCsv(Path inFilePath, char delimiter) throws NumberFormatException, IOException { ArrayList retList = new ArrayList(); int numberOfCSVLines = countLines(inFilePath); numberOfCSVLines = numberOfCSVLines - 1; //take into account header CsvReader cvsReader = new CsvReader(inFilePath.toString()); cvsReader.setDelimiter(delimiter); int i = 0; cvsReader.readHeaders(); String[] headers = cvsReader.getHeaders(); retList.add(headers); double[][] mlDouble = new double[numberOfCSVLines][headers.length]; while (cvsReader.readRecord()) { String[] rows = cvsReader.getValues(); int j = 0; for (String col : rows) { if (j > 1) { mlDouble[i][j - 2] = (col != null) ? Double.parseDouble(col) : 0.0; } j++; } i++; if (i >= numberOfCSVLines) { break; } } retList.add(mlDouble); return retList; }
Example 14
Source File: RulesDbClientImpl.java From ipst with Mozilla Public License 2.0 | 5 votes |
@Override public Collection<RuleId> listRules(String workflowId, RuleAttributeSet attributeSet) { Objects.requireNonNull(workflowId); String path = RULES_PREFIX + workflowId + "/data.csv"; Map<String, String> query = ImmutableMap.of("start", "0", "count", "-1", "headers", "true", "cols", "algoType,contingencyId,indexType"); try { CsvReader csvReader = new CsvReader(httpClient.getHttpRequest(new HistoDbUrl(config, path, query)), ',', StandardCharsets.UTF_8); try { csvReader.setSafetySwitch(false); csvReader.readHeaders(); List<RuleId> ruleIds = new ArrayList<>(); while (csvReader.readRecord()) { String[] values = csvReader.getValues(); ruleIds.add(new RuleId(RuleAttributeSet.valueOf(values[0]), new SecurityIndexId(values[1], SecurityIndexType.fromLabel(values[2])))); } return ruleIds; } finally { csvReader.close(); } } catch (IOException e) { throw new RuntimeException(e); } }
Example 15
Source File: UserBehaviorCsvFileReader.java From blog_demos with Apache License 2.0 | 5 votes |
public UserBehaviorCsvFileReader(String filePath) throws IOException { this.filePath = filePath; try { csvReader = new CsvReader(filePath); csvReader.readHeaders(); } catch (IOException e) { throw new IOException("Error reading TaxiRecords from file: " + filePath, e); } }
Example 16
Source File: Utils.java From sailfish-core with Apache License 2.0 | 4 votes |
public static long determineStartSecFromParsedFile(String parsedFileName) throws IOException { CsvReader parsedReader = new CsvReader(parsedFileName); parsedReader.setSafetySwitch(false); parsedReader.readHeaders(); parsedReader.readRecord(); long startSec = Long.parseLong(parsedReader.getValues()[0]); parsedReader.close(); return startSec; }
Example 17
Source File: CSPARQLAarhusTrafficStream.java From Benchmark with GNU General Public License v3.0 | 4 votes |
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 18
Source File: CQELSAarhusTrafficStream.java From Benchmark with GNU General Public License v3.0 | 4 votes |
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 19
Source File: FileOperation.java From Benchmark with GNU General Public License v3.0 | 4 votes |
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(); }
Example 20
Source File: CSVMappingGenerator.java From GeoTriples with Apache License 2.0 | 4 votes |
public void run() throws IOException { CsvReader reader = new CsvReader(new FileInputStream(pathToShapefile), Charset.defaultCharset()); reader.setDelimiter(separator); reader.setSafetySwitch(false); reader.readHeaders(); // Iterate the rows Path p = Paths.get(pathToShapefile); String tmp = p.getFileName().toString(); String typeName = tmp.substring(0, tmp.lastIndexOf('.')); triplesMaps.put(typeName, ""); triplesMaps.put(typeName, triplesMaps.get(typeName) + printTriplesMap(typeName)); triplesMaps.put(typeName, triplesMaps.get(typeName) + printLogicalSource(typeName)); triplesMaps.put(typeName, triplesMaps.get(typeName) + printSubjectMap(baseURI, typeName)); boolean hasgeometry = false; String typeNameGeo = typeName + "_Geometry"; WKTReader wktReader = new WKTReader(); String geometry_identifier = null; boolean has_record = reader.readRecord(); for (String header : reader.getHeaders()) { String identifier = header; if (identifier.equalsIgnoreCase("the_geom")) { geometry_identifier = identifier; hasgeometry = true; continue; } if (has_record) { try { if (wktReader.read(reader.get(identifier)) != null) { hasgeometry = true; geometry_identifier = identifier; continue; } } catch (ParseException e1) { System.err.println(reader.get(identifier)); } } String datatype = TranslateDataTypeToXSD("String"); triplesMaps.put(typeName, triplesMaps.get(typeName) + printPredicateObjectMap(identifier, identifier, datatype, typeName)); } if (hasgeometry) { triplesMaps .put(typeName, triplesMaps.get(typeName) + printPredicateObjectMap(true, "hasGeometry", baseURI + (baseURI.endsWith("/") ? "" : "/") + typeName + "/Geometry/{GeoTriplesID}", null, null, "ogc", null, typeName, true, false)); triplesMaps.put(typeNameGeo, ""); triplesMaps.put(typeNameGeo, triplesMaps.get(typeNameGeo) + printTriplesMap(typeNameGeo)); triplesMaps.put(typeNameGeo, triplesMaps.get(typeNameGeo) + printLogicalSource(typeName)); triplesMaps.put(typeNameGeo, triplesMaps.get(typeNameGeo) + printSubjectMap(baseURI, typeName, "ogc", true)); triplesMaps.put(typeNameGeo, triplesMaps.get(typeNameGeo) + printGEOPredicateObjectMaps(geometry_identifier)); } printmapping(); printontology(); }