:: Forum >> Version 2 >>
Tab/Space Delimited instead of CSV
Hello,
I am loading a log file into a CSV table which is then displayed in a grid. My CSV file isnt exactly comma delimited though. Actually the only commas are in a rather large text field and the commas are part of a sentence.
Anyway, is there any way to assign a different delimiter? Or, I do know the lendth of all the colums that come before the text field. The text field is the last column. Could I specify the character length for each field in the row?
Thanks
Aaron
Monday, November 24, 2008
Hello,
I found a post about this, but the author was using version 1. I tried to copy and modify it, but turns out it was originally modified from the original source function. So attempted to do the same with v2.5.3 and this is what I end up with:
table.response = function(text){
this._rows = text.split(/\r*\n/);
if (!this._rows[this._rows.length-1]){
this._rows.pop(); // remove the last line if empty
}
var i, s, rows = [], a = text.split(/\r*\n/);
for (i=0; i<a.length; i++) {
if (a[i]) {
rows[i] = new Array(a[i].substr(0,10), a[i].substr(11,11), a[i].substr(27,1), a[i].substr(29,14), a[i].substr(44,a[i].length));
}
}
this._data = rows;
if (this.$owner) {
this.$owner.clearScrollModel();
this.$owner.clearSelectedModel();
this.$owner.clearSortModel();
this.$owner.clearRowModel();
this.$owner.setRowCount(this.getCount());
this.$owner.refresh();
}
};
Seems to work great. One further question...Do I need to duplicate everything from the original source function? Specifically, the bottom part where there are quite a few clear commands.
Aaron
Monday, November 24, 2008
This topic is archived.
Back to support forum
Forum search