1. Reading sequences from a file
- Posted by dstanger at belco.bc.ca Jun 11, 2001
- 363 views
Evening all, I saved a bunch of sequences to a file using open(), etc, and now I want to read them again but when I do the brackets and commas in the sequences are being read along with the numeric data within. I have tried gets() and getc() with no luck. Can anyone suggest a way to read just the numeric data from the sequences? Thank God for the mailing list! Thanks, David S
2. Re: Reading sequences from a file
- Posted by "Thomas Parslow (PatRat)" <patrat at rat-software.com> Jun 11, 2001
- 357 views
> Evening all, > I saved a bunch of sequences to a file using open(), etc, and now I want to > read them again but when I do the brackets and commas in the sequences are > being read along with the numeric data within. I have tried gets() and > getc() with no luck. Can anyone suggest a way to read just the numeric data > from the sequences? > Thank God for the mailing list! > Thanks, > David S What you want here is the get() function from get.e (see library.doc)... Thomas Parslow (PatRat) ICQ #:26359483 Rat Software http://www.rat-software.com/ Please leave quoted text in place when replying
3. Re: Reading sequences from a file
- Posted by Irv Mullins <irvm at ellijay.com> Jun 11, 2001
- 340 views
----- Original Message ----- > Evening all, > > I saved a bunch of sequences to a file using open(), etc, and now I want to > read them again but when I do the brackets and commas in the sequences are > being read along with the numeric data within. I have tried gets() and > getc() with no luck. Can anyone suggest a way to read just the numeric data > from the sequences? You can read or write an entire sequence, no matter how complex or nested it may be, with one command - print() or get() include get.e -- where the get() command lives atom fn sequence s, x s = {"Sue","Tim","Bonnie",2,4,15.125} fn = open("myData","w") print(fn,s) close(fn) fn = open("myData","r") x = get(fn) if x[1] = GET_SUCCESS then x = x[2] -- chech for read errors end if close(fn) Note: using Euphoria's standard print() function will save strings to disk in numeric form {83,114,123,... which makes strings hard to read with a text editor. They will read back into Euphoria programs correctly, however. If you think you may want to be able to read and perhaps edit these disk files, then download Gabriel Boheme's replacement print.e from the RDS website. It will write these to disk as {"Sue","Tim","Bonnie",2,4,15.125}just as you would expect. And it saves some disk space as well. Just add include print.e at the top of your file. No other changes are needed. Regards. Irv