Re: ReadList query
- To: mathgroup at smc.vnet.net
- Subject: [mg27681] Re: [mg27671] ReadList query
- From: Ken Levasseur <Kenneth_Levasseur at uml.edu>
- Date: Sun, 11 Mar 2001 04:04:24 -0500 (EST)
- References: <200103100550.AAA15850@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Bob:
I've assumed that you have text file that looks something link this:
In[5]:=
!! rlh.txt
3000; 2,3; 3000; 3,5;3000; 2,3; 4000; 3,5;
1000; 2,3; 5000; 4,5;
4000; 2,7; 8000; 3,5
If so, the following steps will produce the list of ordered pairs that
you're looking for.
In[1]:=
OpenRead["rlh.txt"]
Out[1]=
InputStream[rlh.txt, 21]
In[2]:=
longstring = StringJoin[ReadList["rlh.txt", String]]
Out[2]=
3000; 2,3; 3000; 3,5;3000; 2,3; 4000; 3,5;1000; 2,3; 5000;\
4,5;4000; 2,7; 8000; 3,5
In[3]:=
Close["rlh.txt"]
Out[3]=
rlh.txt
In[4]:=
Characters["{" <> longstring <>
"}"] // (# /. {"," -> "."}) & // (# /. {";" -> ","}) & //
StringJoin // ToExpression // Partition[#, 2] &
Out[4]=
{{3000, 2.3}, {3000, 3.5}, {3000, 2.3}, {4000, 3.5},
{1000, 2.3}, {5000, 4.5}, {4000, 2.7}, {8000, 3.5}}
Ken Levasseur
Math. Sciences
UMass Lowell
Robert-Lewis HYDE wrote:
> Help please,
>
> I have a long series of data as;
>
> 3000; 2,3; 3000; 3,5; ...........
>
> I would like to Read this as
>
> {{3000, 2.3},{3000, 3.5},...........}}
>
> in order to Plot etc.
>
> What is the code please ?
>
> bob
- References:
- ReadList query
- From: Robert-Lewis HYDE <bobhyde@wanadoo.fr>
- ReadList query