:: Forum >>

load text from pipe ('|') delimited flat file

is possible change quickly the separator of data of a flat database?
ps : thanks for the great job you made
roberto
Thursday, February 3, 2005
is it possible modify the table response to use a flat db |separated in this way?
-->

table.response = function(text){
var i, s, table = [], a = text.split(/\r*\n/);
for (i=0; i<a.length; i++) {
if (a) {table[i] = a.split("|")}
}
this._data = table;
Active.HTTP.Request.prototype.response.call(this);
};
roberto
Tuesday, March 1, 2005
The above code had a bug. a.split needs to be a[i].split. Here is code I am using:

table.response = function(text) {
var i, s, rows = [], a = text.split(/\r*\n/);
for (i=0; i<a.length; i++) {
if (a[i]) {
rows[i] = a[i].split("|")
}
}
this._data = rows;
Active.HTTP.Request.prototype.response.call(this);
};
Ken
Saturday, March 26, 2005
Hi I have been having the same problem with the pipe, even using the chr code for it will not work.

In the end I used a string replace function first to change the pipe to something like a comma first then it works fine, of course if you are using a comma elsewhere in the text then use something like @@ as your demiliter.

Hope that helps, it worked for me..
Gareth Shaw
Wednesday, October 12, 2005

This topic is archived.


Back to support forum

Forum search