// open csv file in write mode and save the title to it.
function initializeCsvFile() {
var str = '';
var fields = ["header1", "header2"];
// build title line
var line = '';
for (var f = 0; f < fields.length; ++f) {
if (line != '') line += '|'
line += fields[f];
}
str += line + '\n';
var fs = require('fs');
fs.write(csv_file, str, 'w');
casper.log("csv_file: " + csv_file);
casper.log("str: " + str);
fs.close();
}
casper.start(function() {
initializeCsvFile();
});
casper.run(function() {
this.exit();
});