MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Import[ ] & ReadList[ ]; "Word" and "Record"

  • To: mathgroup at smc.vnet.net
  • Subject: [mg40388] Re: Import[ ] & ReadList[ ]; "Word" and "Record"
  • From: Bill Rowe <listuser at earthlink.net>
  • Date: Thu, 3 Apr 2003 01:45:13 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

On 4/2/03 at 4:35 AM, b90401114 at ntu.edu.tw (neuron) wrote:

>1. What's the difference between Import[ ] & ReadList?

Basically, Import is pre-programmed to understand a lot of specific file formats and ReadList isn't. The built in knowledge of Import about certain file types makes it much simpler to read the data from these files into Mathematica than would otherwise be the case. But there is a performance cost associated with Import.

To give a specific example, suppose you had a spreadsheet file save as a tab deliminated file that contained a mixture of both numeric and non-numeric data. Then

Import[filename, "Table"] would read all of the data in correctly maintaining the data structure. Numeric data would be read in as numbers ready to use in further computation. OTOH, 

ReadList[filename, Number, RecordLists->True] 

would generate errors and fail when the non-numeric data was encountered. The errors could be avoided with

ReadList[filename, Word, RecordLists->True]

but now all of the data would be type String and would not be ready for further computations without additional programming.

If the file had the same format but contained only numeric data,

Import[filename,"Table"] and
ReadList[filename, Number, RecordLists->True]

would have identical results but ReadList would execute faster.

>2.Are the two types "Word" and have different meanings?

Not as far as I know.


  • Prev by Date: Re: multistep iterative methods
  • Next by Date: Re: Show graphics command
  • Previous by thread: Import[ ] & ReadList[ ]; "Word" and "Record"
  • Next by thread: Re: Import[ ] & ReadList[ ]; "Word" and "Record"