MathGroup Archive 1996

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

Search the Archive

Re: Re: Re: Re: help! to input data...

  • To: mathgroup at smc.vnet.net
  • Subject: [mg4565] Re: [mg4463] Re: [mg4394] Re: [mg4228] Re: help! to input data...
  • From: Allan Hayes <hay at haystack.demon.co.uk>
  • Date: Fri, 16 Aug 1996 05:15:00 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

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 at haystack.demon.co.uk

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

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

welter at .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 at haystack.demon.co.uk

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

==== [MESSAGE SEPARATOR] ====


  • Prev by Date: Windows fonts (v2.2.2 & 2.2.3)
  • Next by Date: The Mathematica Handbook (cost)
  • Previous by thread: Windows fonts (v2.2.2 & 2.2.3)
  • Next by thread: The Mathematica Handbook (cost)