Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Re: [mg4463] Re: [mg4394] Re: [mg4228] Re: help! to input data...
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Allan Hayes

Posts: 1,508
Registered: 12/6/04
Re: [mg4463] Re: [mg4394] Re: [mg4228] Re: help! to input data...
Posted: Aug 2, 1996 2:03 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


CORRECTION:

I am grateful to Sergio Rescia for pointing out that I did not
complete the renaming of variables in the code in [mg4463]
(copied below).
Here is what it should have been -- with (**) against changed lines.

getdata[file_String]:=
Module[{temp, ind, starts, ends, takes,n},
temp = ReadList[file,Word,RecordLists->True];
temp = Map[ToExpression,temp,{2}];
temp = DeleteCases[DeleteCases[temp, $Failed|#1,{2}],{},2];
starts = Position[temp, {1,__}]//Flatten; (**)
ends = Append[Rest[starts]-1, Length[temp]]; (**)
takes = Transpose[{starts, ends}];
n=1; Prepend[Take[temp, #],n++]&/@takes
]

Allan Hayes
hay@haystack.demon.co.uk

********************
----- Begin Included Message -----

From mathgroup-adm@smc.vnet.net Tue Jul 30 19:36:18 1996
Date: Mon, 29 Jul 1996 02:37:19 -0400
From: Allan Hayes <hay@haystack.demon.co.uk>
To: mathgroup@smc.vnet.net
Subject: [mg4463] Re: [mg4394] Re: [mg4228] Re: help! to input data...

welter@.ti.com (Jason Welter)
[mg4394] Re: [mg4228] Re: help! to input data...

Asks
>>>>>>>>>>>>>>>>>>>>>>>>.
John[John Fultz], do you know of a way to read this into MMA:

Intradie---> [ACON]
# TestName[ACT245P ] [ PMC1] [ PMC2] [ PMC3] [
PMC4] [ PMC5]
---------------------- ---------- ---------- ----------
---------- ----------
1 [CONTI_M1 ] & 0.00000 & 1.00000 & 1.00000 &
1.00000 & 2.00000

Intradie---> [ACHNB]
# TestName[ACT245P ] [ PMC1] [ PMC2] [ PMC3] [
PMC4] [ PMC5]
---------------------- ---------- ---------- ----------
---------- ----------
2 [CA_GOI_GOE_NM ] -19.5000 -19.3000 -19.6000
-20.0000 -19.7000
3 [CA_GOI_GOE_PM ] 18.0000 17.8000 18.0000
18.4000 18.2000
4 [CH_1.00_NM_TR ] 121.853 115.612 188.382
168.093 273.507
5 [CH_1.00_NM_TH ] 125.392 162.555 164.442
244.348 251.892
6 [CH_1.00_PM_TR ] 3.44601 3.30223 3.10842
3.45061 4.58194
7 [CH_1.00_PM_TH ] 2.25403 2.03261 2.07853
2.33058 3.10277

Intradie---> [ACON]
# TestName[ACT245P ] [ PMC1] [ PMC2] [ PMC3] [
PMC4] [ PMC5]
---------------------- ---------- ---------- ----------
---------- ----------
1 [CONTI_M1 ] & 0.00000 & 1.00000 & 1.00000 &
1.00000 & 2.00000

Intradie---> [ACHNB]
# TestName[ACT245P ] [ PMC1] [ PMC2] [ PMC3] [
PMC4] [ PMC5]
---------------------- ---------- ---------- ----------
---------- ----------
2 [CA_GOI_GOE_NM ] -19.5000 -19.3000 -19.6000
-20.0000 -19.7000
3 [CA_GOI_GOE_PM ] 18.0000 17.8000 18.0000
18.4000 18.2000
4 [CH_1.00_NM_TR ] 121.853 115.612 188.382
168.093 273.507
5 [CH_1.00_NM_TH ] 125.392 162.555 164.442
244.348 251.892
6 [CH_1.00_PM_TR ] 3.44601 3.30223 3.10842
3.45061 4.58194
7 [CH_1.00_PM_TH ] 2.25403 2.03261 2.07853
2.33058 3.10277


etc.

I have about a dozen files each hundreds of K large and am having
to load it into Excel, parse & sort & prep for mathematica. I need
the numbers to be recognized as numbers by MMA, not characters.
Ideally the data would look like:

{{1,{1,0.00000,1.00000,1.00000,1.00000,2.00000},
{2,-19.500,-19.300,-19.600,-20.000,-19.700},
{3,18.0000,17.8000,18.0000,18.4000,18.2000},
{4,121.853,115.612,188.382,168.093,273.507},
{5,125.392,162.555,164.442,244.348,251.892},
{6,3.44601,3.30223,3.10842,3.45061,4.58194},
{7,2.25403,2.03261,2.07853,2.33058,3.10277}},
{2,{1,0.00000,1.00000,1.00000,1.00000,2.00000},
{2,-19.500,-19.300,-19.600,-20.000,-19.700},
{3,18.0000,17.8000,18.0000,18.4000,18.2000},
{4,121.853,115.612,188.382,168.093,273.507},
{5,125.392,162.555,164.442,244.348,251.892},
{6,3.44601,3.30223,3.10842,3.45061,4.58194},
{7,2.25403,2.03261,2.07853,2.33058,3.10277}}}
>>>>>>>>>>>>>>>>>>>>>>.

Jason,
Here is a first attempt.

getdata[file_String]:=
Module[{temp, ind, starts, ends, takes,n},
temp = ReadList[file,Word,RecordLists->True];
temp = Map[ToExpression,temp,{2}];
temp = DeleteCases[DeleteCases[temp, $Failed|#1,{2}],{},2];
starts = Position[data2, {1,__}]//Flatten;
ends = Append[Rest[pos]-1, Length[data2]];
takes = Transpose[{starts, ends}];
n=1; Prepend[Take[temp, #],n++]&/@takes
]


I called your file fileHelp.


getdata["fileHelp"]//Timing

{0.25 Second,
{
{1, {1, 0., 1., 1., 1., 2.},
{2, -19.5, -19.3, -19.6, -20., -19.7},
{3, 18., 17.8, 18., 18.4, 18.2},
{4, 121.853, 115.612, 188.382, 168.093, 273.507},
{5, 125.392, 162.555, 164.442, 244.348, 251.892},
{6, 3.44601, 3.30223, 3.10842, 3.45061, 4.58194},
{7, 2.25403, 2.03261, 2.07853, 2.33058, 3.10277},
},

{2, {1, 0., 1., 1., 1., 2.},
{2, -19.5, -19.3, -19.6, -20., -19.7},
{3, 18., 17.8, 18., 18.4, 18.2},
{4, 121.853, 115.612, 188.382, 168.093, 273.507},
{5, 125.392, 162.555, 164.442, 244.348, 251.892},
{6, 3.44601, 3.30223, 3.10842, 3.45061, 4.58194},
{7, 2.25403, 2.03261, 2.07853, 2.33058, 3.10277}}
}
}

Allan Hayes
hay@haystack.demon.co.uk

----- End Included Message -----







Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.