Sorting text-file data into list lists
- To: mathgroup at smc.vnet.net
- Subject: [mg46234] Sorting text-file data into list lists
- From: "Curt Fischer" <crf3 at po.cwru.edu>
- Date: Thu, 12 Feb 2004 07:15:59 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
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