Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Re: help! to input data...
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Dave Wagner

Posts: 19
Registered: 12/7/04
Re: help! to input data...
Posted: Jun 18, 1996 3:05 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

In article <4q09hb$g8c@dragonfly.wolfram.com>,
Paul Abbott <paul@earwax.pd.uwa.edu.au> wrote:
>Ian Collier wrote:
>

>> Mathematica's ReadList command does not have any built-in options to
>> read comma-separated data.

>
>
>A not so neat alternative is:
>
>In[4]:= ReadList["comma.dat", Table[Word,{3}], WordSeparators->","]
>


The not-so-neat alternative is required if the data has been output
by a spreadsheet program like excel, which does not represent zero-valued
entries in the file, e.g.,

1,,3,4,5
6,7,,,10

You need to use

ReadList["comma.dat", Word, RecordLists->True,
WordSeparators->","]

Note that the RecordLists option obviates the need to specify how
many items are on each line. (In fact, the code shown works even when there
are a different number of items on each line.)

For the above data, you'll get something like this:

{"1", "", "3", etc.

When you convert this ToExpression, each "" will turn into Null, which
can easily be replaced with 0's using a rule.

Dave Wagner
Principia Consulting
(303) 786-8371
dbwagner@princon.com
http://www.princon.com/princon







Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.