MathGroup Archive 1999

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

Search the Archive

InputStream in version 3 vs version 4

  • To: mathgroup at smc.vnet.net
  • Subject: [mg18773] InputStream in version 3 vs version 4
  • From: "ELLIS, Luci" <EllisL at rba.gov.au>
  • Date: Tue, 20 Jul 1999 01:33:30 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Hi MathGroupers,
I am trying to read in a standard tab-delimited text file of data. It works
under version 3, but not version 4, and I have no idea why.  I tried setting
the DOSTextFormat option to False, and that didn't help. There didn't appear
to be anything in the manual indicating that this function had changed in
version 4. Does anyone have any suggestions? If it helps, I'm using NT.

In[1]:=
NSeries = 4;
In[2]:=
HeaderType = Table[Word, {NSeries + 1}]
Out[2]=
{Word, Word, Word, Word, Word}
In[3]:=
InFile = OpenRead["QuartEcoTest.txt"]
Out[3]=
InputStream["QuartEcoTest.txt", 5]
In[4]:=
Streams[]
Out[4]=
{OutputStream["stdout", 1], OutputStream["stderr", 2],
InputStream["QuartEcoTest.txt", 5]}
In[5]:=
EcoLabels = Read[InFile, HeaderType]
Out[5]=
{"Series", "GDP", "NFGDP", "GDPDEF", "NFGDPDEF"}
In[8]:=
DataType = Prepend[Table[Number, {NSeries}], Word]
Out[8]=
{Word, Number, Number, Number, Number}
In[9]:=
EcoData = ReadList[InFile, DataType, RecordLists -> True];
Read::"readn": "Syntax error reading a real number from \
\!\(\"QuartEcoTest.txt\"\)."
In[10]:=
EcoData // InputForm
Out[10]//InputForm=
{{{"", $Failed, EndOfFile, EndOfFile, EndOfFile}}}

The data looks like this (with more rows, of course).  The point is that I
want to keep the headings and first column as text, 
Series	GDP	NFGDP	GDPDEF	NFGDPDEF
Sep-89	108379.0	105023.0	86.5	85.5
Dec-89	108768.0	105231.0	86.8	86.0
Mar-90	109335.0	105769.0	88.7	88.1
Jun-90	109885.0	106371.0	89.2	88.7
Sep-90	109241.0	105519.0	90.2	90.4
Dec-90	109339.0	105552.0	90.7	91.1
Mar-91	108692.0	105250.0	91.2	91.6

Failing this, can anyone suggest a robust way to turn a list of functions
and a matrix of data into a matrix where the elements of each row are the
elements of the original matrix transformed by the corresponding function?

That is:
functions= {f[#]&, g[#]&, h[#]&}
data = {{data[1,1],data[1,2],data[1,3]},{data[2,1],data[2,2],data[2,3},
{data[3,1],data[3,2],data[3,3},
{data[4,1],data[4,2],data[4,3]},{data[5,1],data[5,2],data[5,3}}

output= {f[data[1,1]], g[data[1,2]], h[data[1,3]]}, {f[data[2,1]],
g[data[2,2]], h[data[2,3]]}, {f[data[3,1]], g[data[3,2]], h[data[3,3]]},
{f[data[4,1]], g[data[4,2]], h[data[4,3]]}, {f[data[5,1]], g[data[5,2]],
h[data[5,3]]}, 

I've tried various combinations of Map, MapThread, Thread and Inner without
success.

Thanks,
Luci

____________________________________________________
Luci Ellis                         ph:61-2-9551-8881
Acting Senior Economist            fx:61-2-9551-8833
Financial & Monetary Conditions    ellisl at rba.gov.au
Economic Analysis Department       GPO Box 3947
Reserve Bank of Australia          Sydney NSW 2001
My opinions are not those of my employer


  • Prev by Date: [Q] Thread[] and Hold[]
  • Next by Date: Re: Re: Rudimentary Spell Checker
  • Previous by thread: Re: [Q] Thread[] and Hold[]
  • Next by thread: Re: InputStream in version 3 vs version 4