MathGroup Archive 2002

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

Search the Archive

ReadList under Mac OS X and Mac OS 9

  • To: mathgroup at smc.vnet.net
  • Subject: [mg33785] ReadList under Mac OS X and Mac OS 9
  • From: Cheng Liu <cliu at lanl.gov>
  • Date: Tue, 16 Apr 2002 03:50:39 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Dear group,

	I've migrated to Mac OS X and started using Mathematica 4.1 for
Mac OS X for quite some times.  Everything seems fine until recently I
noticed that the behavior of ReadList has changed under OS X from what
I'm used to under OS 9.  To illustrate this I did the following.

First, I generate a text file using BBEdit (the format is similar to 
the data files I'm dealing with)

0.0178,0.000,0.33952,****,0.340
-0.0028,1.000,0.31952,****,0.320
-0.0244,1.500,0.30952,****,0.310
-0.0019,2.000,0.29952,****,0.300
-0.0225,2.500,0.28952,****,0.290

Then save the file with different line breaking options for DOS, Mac, 
and Unix, respectively.

Under Mac OS X 10.1.3

In[1]:=
SetDirectory["/Volumes/Macintosh HD/Polymeric Foam/Foam DIC Test/Test05"];
(*SetDirectory["Macintosh HD:Polymeric Foam:Foam DIC Test:Test05"];*)

In[2]:=
$Version

Out[2]=
4.1 for Mac OS X (November 5, 2001)

In[3]:=
!!TestTextDos.txt

 From In[3]:=
0.0178,0.000,0.33952,****,0.340

-0.0028,1.000,0.31952,****,0.320

-0.0244,1.500,0.30952,****,0.310

-0.0019,2.000,0.29952,****,0.300

-0.0225,2.500,0.28952,****,0.290


In[4]:=
!!TestTextMac.txt

 From In[4]:=
0.0178,0.000,0.33952,****,0.340
-0.0028,1.000,0.31952,****,0.320
-0.0244,1.500,0.30952,****,0.310
-0.0019,2.000,0.29952,****,0.300
-0.0225,2.500,0.28952,****,0.290

In[5]:=
!!TestTextUnix.txt

 From In[5]:=
0.0178,0.000,0.33952,****,0.340
-0.0028,1.000,0.31952,****,0.320
-0.0244,1.500,0.30952,****,0.310
-0.0019,2.000,0.29952,****,0.300
-0.0225,2.500,0.28952,****,0.290

In[6]:=
ReadList["TestTextDos.txt", Word, WordSeparators\[Rule]",",
   RecordLists\[Rule]True]

Out[6]=
{{0.0178,0.000,0.33952,****,0.340
},{-0.0028,1.000,0.31952,****,0.320
},{-0.0244,1.500,0.30952,****,0.310
},{-0.0019,2.000,0.29952,****,0.300
},{-0.0225,2.500,0.28952,****,0.290
}}

In[7]:=
ReadList["TestTextMac.txt", Word, WordSeparators\[Rule]",",
   RecordLists\[Rule]True]

Out[7]=
{{0.0178,0.000,0.33952,****,0.340
-0.0028,1.000,0.31952,****,0.320
-0.0244,1.500,0.30952,****,0.310
-0.0019,2.000,0.29952,****,0.300
-0.0225,2.500,0.28952,****,0.290
}}

In[8]:=
ReadList["TestTextUnix.txt", Word, WordSeparators\[Rule]",",
   RecordLists\[Rule]True]

Out[8]=
{{0.0178,0.000,0.33952,****,0.340},{-0.0028,1.000,0.31952,****,
     0.320},{-0.0244,1.500,0.30952,****,0.310},{-0.0019,2.000,0.29952,****,
     0.300},{-0.0225,2.500,0.28952,****,0.290}}

Same file running under Mac OS 9.2

In[1]:=
(*SetDirectory["/Volumes/Macintosh HD/Polymeric Foam/Foam DIC Test/Test05"];*)
SetDirectory["Macintosh HD:Polymeric Foam:Foam DIC Test:Test05"];

In[2]:=
$Version

Out[2]=
4.1 for Power Macintosh (November 2, 2000)

In[3]:=
!!TestTextDos.txt

 From In[3]:=
0.0178,0.000,0.33952,****,0.340

-0.0028,1.000,0.31952,****,0.320

-0.0244,1.500,0.30952,****,0.310

-0.0019,2.000,0.29952,****,0.300

-0.0225,2.500,0.28952,****,0.290


In[4]:=
!!TestTextMac.txt

 From In[4]:=
0.0178,0.000,0.33952,****,0.340
-0.0028,1.000,0.31952,****,0.320
-0.0244,1.500,0.30952,****,0.310
-0.0019,2.000,0.29952,****,0.300
-0.0225,2.500,0.28952,****,0.290

In[5]:=
!!TestTextUnix.txt

 From In[5]:=
0.0178,0.000,0.33952,****,0.340
-0.0028,1.000,0.31952,****,0.320
-0.0244,1.500,0.30952,****,0.310
-0.0019,2.000,0.29952,****,0.300
-0.0225,2.500,0.28952,****,0.290

In[6]:=
ReadList["TestTextDos.txt", Word, WordSeparators\[Rule]",",
   RecordLists\[Rule]True]

Out[6]=
{{0.0178,0.000,0.33952,****,0.340},{
-0.0028,1.000,0.31952,****,0.320},{
-0.0244,1.500,0.30952,****,0.310},{
-0.0019,2.000,0.29952,****,0.300},{
-0.0225,2.500,0.28952,****,0.290},{
}}

In[7]:=
ReadList["TestTextMac.txt", Word, WordSeparators\[Rule]",",
   RecordLists\[Rule]True]

Out[7]=
{{0.0178,0.000,0.33952,****,0.340},{-0.0028,1.000,0.31952,****,
     0.320},{-0.0244,1.500,0.30952,****,0.310},{-0.0019,2.000,0.29952,****,
     0.300},{-0.0225,2.500,0.28952,****,0.290}}

In[8]:=
ReadList["TestTextUnix.txt", Word, WordSeparators\[Rule]",",
   RecordLists\[Rule]True]

Out[8]=
{{0.0178,0.000,0.33952,****,0.340
-0.0028,1.000,0.31952,****,0.320
-0.0244,1.500,0.30952,****,0.310
-0.0019,2.000,0.29952,****,0.300
-0.0225,2.500,0.28952,****,0.290
}}

Note that using !!FileName yields the same result for both Mac and Unix
files.  I know that Mac OS X is based on the FreeBSD and Mathematica 4.1 for
Mac OS X is based on its Unix cousin.  But I do have and continue to generate
a lot of text files with the Mac line breaking, and I want to know what should
I do so that ReadList will behave the same on both Mac and Unix type of text
files.  Thanks.

Sincerely

Cheng

-- 
====================================================
Cheng Liu, Ph.D.
MST-8, Structure/Property Relations
Materials Science and Technology Division
Los Alamos National Laboratory
Los Alamos, New Mexico 87545

Phone: 505-665-6892 (office), 505-667-9950 (lab)
Fax:   505-667-8021
email: cliu at lanl.gov
====================================================


  • Prev by Date: RE: Interval arithmetic, of a sort
  • Next by Date: Can I do MultipleListPlot with Color?
  • Previous by thread: Making Tensor operations more efficient
  • Next by thread: Can I do MultipleListPlot with Color?