Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

ReadList and columns

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73873] ReadList and columns
  • From: "Mary Beth Mulcahy" <mulcahy.marybeth at gmail.com>
  • Date: Fri, 2 Mar 2007 06:37:59 -0500 (EST)

Using Mathematicas Experimental Data Analysis (EDA) I have successfully
written a notebook to import and plot numerous files.  EDA has some nice
functions for importing data which include ignoring headers and specifying
columns of data.  Unfortunately my colleague doesn't have EDA so I have been
trying to write the script necessary to import the data the same way I have
with EDA so that he can use my program.  I am close, but am at a stopping
point I was hoping someone could help with.

First, here is the one line of code I use in EDA to get my data ready:

au1=Table[ImportData["C:\Documents and Settings\All
Users\Documents\msb_chemistry\Argentina\ellipsometry\Gold\cavities\g500\Au5001.txt",HeaderLines->4,
OutputVariables->1, UseVariables->i], {i, 1,19}];


Here is what I have written to try and get my data into the same format not
using EDA:

strm=OpenRead["C:\Documents and Settings\All
Users\Documents\msb_chemistry\Argentina\ellipsometry\Gold\cavities\g500\Au5001show.txt"];


Skip[strm, Record, 4, NullRecords->False];  (*this is to eliminate 4 header
lines*)

au1=ReadList[strm, Table[Number, {i, 1, 19}]]; (this is to then import the
data into a table*)

Close[strm];

Here is sample of what au1  then looks like according to Mathematica:

 {{350,0.00023179,0.0001804},{360,0.0038609,0.002927},{370,0.0075302,
0.0058464},{380,0.008159,0.006915},{390,0.0076243,0.0068103}}

which if I put in table form looks like:

au1//TableForm

350    0.00023179    0.0001804
360    0.0038609    0.002927
370    0.0075302    0.0058464
380    0.008159    0.006915
390    0.0076243    0.0068103


So in the end what I want to do is make a MultipleListPlot using the left
column as the "x" column and then the two other as "y" columns.  Since with
EDA I have been calling each column in as a separate variable, I simply
transpose the two columns I want to plot to get my {x, y} points.  That
doesn't work here.  When I call up the columns, I get a list of individual
numbers:

input:     au1[[All,{1}]]
output:  {{350},{360},{370},{380},{390}}

input:     au1[[All,{2}]]
output:   {{0.00023179},{0.0038609},{0.0075302},{0.008159},{0.0076243}}

And when I try and transpose the lists (Transpose[au1[[All,{1}]], au1[[All,
{2}]]]) I get an error message saying the dimensions of my array are
incorrect.

I know that I need Mathematica to read my columns like this:
{350,360,370,380,390} without the extra curly brackets and which I believe
would be a single array, but I can't figure out how to do it.  I would
really appreciate any help.

Sincerely,
Mary Beth Mulcahy


  • Prev by Date: Re: GNU readline ability in the front end
  • Next by Date: Re: Hold and Equal
  • Previous by thread: Re: "Transparency" with respect to differentiation
  • Next by thread: RE: ReadList and columns