Re: Import[ ] & ReadList[ ]; "Word" and "Record"
- To: mathgroup at smc.vnet.net
- Subject: [mg40445] Re: Import[ ] & ReadList[ ]; "Word" and "Record"
- From: Bill Rowe <listuser at earthlink.net>
- Date: Sat, 5 Apr 2003 04:01:39 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
On 4/4/03 at 1:21 AM, b90401114 at ntu.edu.tw (neuron) wrote:
>Thanks a lot for the answer of question 1 As for question 2 Sorry, I
>lost a word in question 2: 2.Are the two types "Word"& "Record" have
>different meanings?
Yes, Word and Record are different.
With the default settings, Words are any sequence of characters separated by either a tab or space. Records are any sequence of characters separated by newlines.
For example suppose I had the following in a file
aaa bb cc
aaa ddd cc
aaa ff cc
ReadList[file, Word]
{"aaa", "bb", "cc", "aaa", "ddd", "cc", "aaa", "ff", "cc"}
ReadList[file,Record]
{"aaa bb cc", "aaa ddd cc", "aaa ff cc"}
Also, you can specify both the left and right record separators. For example,
ReadList[file,Record,RecordSeparators->{{"aa"},{"c\n"}}]
{"a bb c", "a ddd c", "a ff c"}
It is also possible to set the options so that a record is identical to a word.
For example,
ReadList[file,Word]==ReadList[file,Record,RecordSeparators->{"\n"," "}]
True
But while this is possible it is hard to imagine a case where it would be a good idea. Setting options to make record become the same as word or vice versa will almost certainly lead to confusion later.