Is it possible to read/merge multiple csv files into on file and then sort on a column basis?
Any guidance or sample flow greatly appreciated.
Merging csv files
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
Merging csv files
We have implemented several custom Javascript flow elements to perform similar operations on CSV files for our customers. Complexity depends on whether the files have the same number of columns and they are in the same order.
Dwight Kelly
Apago, Inc.
dkelly@apago.com
Dwight Kelly
Apago, Inc.
dkelly@apago.com
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
Merging csv files
Here's the Javascript basics to read a basic CSV file.
var csvFile = new File( csvFilename );
if (csvFile.exists == false) {
job.log(cLogError, "Could not open CSV file: " + csvFilename);
return false;
}
csvFile.open(File.ReadOnly);
var hdrline = csvFile.readLine();
var separator = ",";
do {
var line = csvFile.readLine();
var i, recTokens = line.split(separator);
for (i=0; i<recTokens.length; i++)
job.log(cLogInfo, recTokens);
} while (!csvFile.eof);
csvFile.close();
var csvFile = new File( csvFilename );
if (csvFile.exists == false) {
job.log(cLogError, "Could not open CSV file: " + csvFilename);
return false;
}
csvFile.open(File.ReadOnly);
var hdrline = csvFile.readLine();
var separator = ",";
do {
var line = csvFile.readLine();
var i, recTokens = line.split(separator);
for (i=0; i<recTokens.length; i++)
job.log(cLogInfo, recTokens);
} while (!csvFile.eof);
csvFile.close();