Re: Sorting text-file data into list lists
- To: mathgroup at smc.vnet.net
- Subject: [mg46263] Re: Sorting text-file data into list lists
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Thu, 12 Feb 2004 22:46:29 -0500 (EST)
- Organization: Universitaet Leipzig
- References: <c0fsmv$c4k$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
Import["practice.txt","CSV"]
is not working ??
Regards
Jens
Curt Fischer wrote:
>
> Dear Group:
>
> I have a large file with lots of numeric data, in matrix form. The rows and
> the columns both have non-numeric text headers. The comma is the delimiter.
> The character at the end of lines shows up as a "paragraph" mark in MS Word;
> I'm assuming it's a carriage return.
>
> I want to import the data into a nested list, like a matrix is usually
> represented in Mathematica. But my attempts using ReadList[] have so far
> failed.
>
> In[1]:=
> !!practice.txt
>
> col1 , col2,
> row1 , 1.00 ,, 2.00,
> row2 , 3.00 , -4.00
>
> In[25]:=
> prac=ReadList["practice.txt", Record,
> RecordSeparators\[Rule]{",","\n"},RecordLists\[Rule]True]
>
> Out[25]=
> {{ col1 },{ col2},{row1 },{
> 1.00 },{ 2.00},{row2 },{ 3.00 },{ -4.00}}
>
> In[27]:=
> ToExpression[prac]
>
> Out[27]=
> {{col1},{col2},{row1},{1.},{2.},{row2},{3.},{-4.}}
>
> What I'd like is something like {{col1, col2},{row1, 1., 2.},{row2, 3., 4.}}
>
> What am I doing wrong? Thanks for any insights.
>
> --
> Curt Fischer