3.2.0

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.

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

table.response = function(text){
        var i, s, table = [], a = text.split(/\r*\n/);

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

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

        this._data = table;
        Active.HTTP.Request.prototype.response.call(this);
    };
Alex (ActiveWidgets)
February 23,
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
AcidRaZor
February 24,
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)
February 25,
Where does this code go?
RL
November 30,

This topic is archived.

See also:


Back to support forum