readAsText: Save every line as an element in an array

126 views
Skip to first unread message

Joko

unread,
Feb 13, 2012, 12:34:11 AM2/13/12
to phonegap
Hello, I'm new in programming with JavaScript and have just
experiences in Python.
Actually I want to read a file and save every line as an element in an
array. Reading the file works great but I don't understand how I can
write every line to my array.

Thanks in advance ....

Kerri Shotts

unread,
Feb 13, 2012, 1:25:31 AM2/13/12
to phon...@googlegroups.com
Once it's read, you can split it up, like so:

var myArray = whatIRead.split("\r"); // split on UNIX-style line-endings (try \r\n or \n, depending on your line endings.)

Should work just fine...

Giacomo Balli

unread,
Feb 13, 2012, 1:58:14 AM2/13/12
to phonegap
you might want to clean with regexp first (double returns etc)

Joko

unread,
Feb 14, 2012, 2:32:06 AM2/14/12
to phonegap
Worked great! Thank You!
Reply all
Reply to author
Forward
0 new messages