Discussion:
"read-line-as-list with-delimiter" bug
idevx
2005-08-05 05:20:34 UTC
Permalink
Hi, I've been trying to use the "read-line-as-list
with-delimiter" method of the File class, but it
doesn't seem to work, always giving me empty lists.
"read-line-as-whitespace-delimited-list" on the other
hand seems to work fine (see sample code below).

I'm trying to load a simple csv (comma separated
values) file, that contains two fields per line, a
filename and a number (an int), separated by a comma.
This is basically a "batch" file for a genetic
algoritm simulation, that has a list of xml file names
to load, followed by the number of generations each
simulation (encoded in the xml) is to be run.

Test data file:
sim657.xml,100
sim123.xml,50
sim987.xml,80
...

I can't use spaces as delimiters, since those are
valid filename/path characters, so
"read-line-as-whitespace-delimited-list" is not an
option for me in this case. (It would work on the
sample data file I posted above if I replaced "," with
" ", but if the files have paths or filenames with
spaces it becomes a problem)

Code:
...
myList (list).
myFile = new File.
myFile open-for-reading with-file
currentFileName.
while (!(myFile is-end-of-file)):
{
# doesn't work:
#myList = (myFile read-line-as-list
with-delimiter ",").

# works fine:
myList = (myFile
read-line-as-whitespace-delimited-list).

print myList{0}, myList{1}.
}
...

I'm using the latest version of breve (OS X), from the
link posted on this list a couple of weeks ago (it
says version 2.2.1, but I think it is actually 2.3b)

Cheers,
Ignacio


------------
http://www.wirelesshamster.com

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar

Loading...