Re: Reading numerical data from a file which also contains a text
- To: mathgroup at smc.vnet.net
- Subject: [mg92837] Re: Reading numerical data from a file which also contains a text
- From: annetts729 <davidannetts at aapt.net.au>
- Date: Tue, 14 Oct 2008 05:00:23 -0400 (EDT)
- References: <gcv7lj$e69$1@smc.vnet.net>
Hi Toshi,
> id
> 1
> =beg=50800 (Nodal Coordinates)
> 1 0.000000E+00 0.000000E+00
> 2 0.150000E+01 0.000000E+00
> 3 0.150000E+01 0.150000E+01
> 4 0.000000E+00 0.150000E+01
>
> I want to read the coordinates of nodes 1~4.
The simplest approach with V6 is to use Import & Drop
idata = Import["test.t19", "Table"];
idata = Drop[idata, {1, 4}]
If you don't have V6, you can continue using your approach with the
sequence
inpu = OpenRead["test.t19"];
idata = ReadList[inpu, Record]
Close[inpu];
(* now we need to drop the first 4 elements *)
idata = Drop[idata, {1, 4}]
(* and convert the strings to numbers *)
idata = ReadList[StringToStream[#], {Number, Number, Number}] & /@
idata
Regards,
Dave.