3.2.0

How to load CSV file and skip the header?

Hi,

I can load a CSV file using the following codes:

var table = new AW.CSV.Table;
table.setProperty('URL', 'myCsvFile.csv');
table.request();
var DataGrid = new AW.Grid.Extended;
DataGrid.setCellModel(table);
DataGrid.setColumnCount(3);
DataGrid.setHeaderText(["Head1", "Head1", "Head1"]);


But it will load the header line from the file, as a result, my first row in the data grid will be header!! How to I load the CSV file without loading the first line in it?

Thanks..

Peter
Peter
January 26,
You can remove the headers in table.response() callback -

table.response1 = table.response;
table.response = function(text){
    text = text.replace(/^.+\r*\n/, "");
    this.response1(text);
}
Alex (ActiveWidgets)
January 26,
Thanks a lot, Alex. It works perfectly!!
Peter
January 26,

This topic is archived.

See also:


Back to support forum