Skip to content

CSV File IO

Sambit Paul edited this page Jan 1, 2021 · 2 revisions

Reading a CSV File

Variable inputFilename contains the path of the file to be read as a string.

Csv readObj = new Csv(','); //comma is the separator
HashMap< String, ArrayList< Object>> out = readObj.readCSV(inputFilename, true);
//true implies that the first row represents the column names

Writing to a WAV File

Variable outputFilename contains the path of the file to be written to as a string.

HashMap< String, ArrayList< Object>> result = new HashMap< String, ArrayList< Object>>();
//Fill the result variable with the key (column names) and ArrayList (content of each column)
Csv writeObj = new Csv(','); //comma is the separator
writeObj.writeCSV(outputFilename, result);
Clone this wiki locally