:: Forum >>
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
Tuesday, February 22, 2005
Anyone?
bowcow
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){
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 ");
s = s.replace(/\t$/, "");
if (s) {table[i] = s.split("\t")}
}
this._data = table;
Active.HTTP.Request.prototype.response.call(this);
};
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
AcidRaZor
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?
RL
Thursday, November 30, 2006
This topic is archived.
Back to support forum
Forum search