:: Forum >> Version 1 >>

Null or Blank value in CSV File

I'm having trouble handling a null or blank value in a CSV file. The table produces a undefined value for the cell, resulting errors while sorting.

Any ideas on how to handle this.

Tuesday, February 22, 2005
Wednesday, February 23, 2005
looks like a bug in CSV parsing (for some reason only in IE?). Maybe you can fix it this way:

table.response = function(text){
istable = [], text.split(/\r*\n/);

pattern = new RegExp("(^|\\t|,)(\"*|'*)(.*?)\\2(?=,|\\t|$)""g");

        for (
i=0i<a.lengthi++) {
s.replace(/\t(?=\t)/g"\t "); //replace empty cells with spaces
s.replace(/\t$/, "");
            if (
s) {table[i] = s.split("\t")}

this._data table;

Alex (ActiveWidgets)
Wednesday, February 23, 2005
I suggest he looks at his data, I'm generating a "csv" file and found I need to have a vbNewLine command afterwards. Also, if there's a breakspace in the data (from your database) it could whack out that csv by 1 line for some strange reason.

It's usually a data problem. Blank or null fields show up as a . or ' in the grid. Undefined means there's inconsitancy in the csv, meaning If you have 5 columns, its a possibility that you only have 4 or something.

Well, thats what I've experienced anyway
Thursday, February 24, 2005
The code above corrects the problem with empty cells in IE. I found that in ie code s.split("\t") produces different results from s.split(/\t/)}

Alex (ActiveWidgets)
Friday, February 25, 2005
Where does this code go?
Thursday, November 30, 2006

This topic is archived.

Back to support forum

Forum search