Remove headers from CSV File using CSV Writer

Hi

I have been through the documentation and made some guesstimates, but have come up at a loss.

Is it possible to use the CSV writer but to not write the headers in the file?

Here is my initialisation script:
// Set the session variables.
session.setVariable( "NEXT", "1" );

// Create CsvWriter with timestamp
CsvWriter writer = new CsvWriter("OmecoDataIn.txt", '|');

// Create Headers Array
String[] header = {"ROWCODE", "DELIVERYCODE", "PHOTO", "COUNTRY", "REGION", "PROVINCE", "VEHICLESTATUS", "TIPOLOGY", "BRAND", "MODEL", "VEHICLEBODY", "EMISSIONS", "COLORS", "YEAR", "WORKHOURS", "KM", "PRICE", "PRICECONDITIONS", "ORIGIN", "LASTREVISION", "WARRANTY", "B2BPRICE", "PUBLISHONLYB2B", "B2BTPLATE", "B2BREFERENT", "B2BAVAILABILITY", "B2BQUANTITY", "NOTE", "RISERVATOLISTECLIENTI", "VARIANT1", "VARIANT2", "VARIANT3", "VARIANT4", "VARIANT5", "VARIANT6", "VARIANT7", "VARIANT8", "NEWTIPOLOGY", "VEHICLEFUEL", "VEHICLEPOWER", "ENGINECAPACITY", "AXLES", "LENGTH", "WIDTH", "NETWEIGHT", "TOTALWEIGHT"};

// Set Headers
writer.setHeader(header);

// Save in session variable for general access
session.setVariable( "WRITER", writer);

And here is my writer script:

c = dataSet.getNumDataRecords();

for (i=0; i {
dr = dataSet.getDataRecord(i);
dr = sutil.tidyDataRecord(dr);
// Retrieve CsvWriter from session variable
writer = session.getv( "WRITER" );

// Write dataRecord to the file (headers already set)
writer.write(dr);

// Flush record to file (write it now)
writer.flush();
}

I would like the file exactly as it appears, just without the header line...?

Many thanks for your help in advance.

Jason

You probably do want to set

You probably do want to set the headers, as the CsvWriter uses that to determine the correct order for the columns. The headers don't get written if the file already exists, so I would:

String fn = "output/filename.csv";

File f = new File(fn);
if (!f.exists())
{
        f.createNewFile();
}

CsvWriter writer = new CsvWriter(fn, '|');

String[] headers = {"Col1","Col2"};
writer.setHeader(headers);
session.setv("WRITER", writer);

Now when you write the first line, the file already exists, and so it will not write the headers.