Re: how to import a block of numbers which may touch each other by "-"
- To: mathgroup at smc.vnet.net
- Subject: [mg85782] Re: how to import a block of numbers which may touch each other by "-"
- From: Bill Rowe <readnewsciv at sbcglobal.net>
- Date: Fri, 22 Feb 2008 05:00:57 -0500 (EST)
On 2/21/08 at 6:06 PM, p.wholey at gmail.com (P.Wholey) wrote: >hello, I have an data file which format is as below: >title: a.file >date: 12 10 2007 >total lines: 100000 >numbers per line: 5 >main data as below: >190 -0.129 0.05772 -0.030 -0.00996 >190 0.071 0.01619 0.039 0.04558 >190 0.121-0.03730 -0.009 -0.00406 >190 0.000-0.00288 0.036 0.01329 >190 0.042-0.00979 -0.112 -0.04337 >190 -0.123 0.07222 0.068 0.04067 >... ... ... >I want to quickly import the main data block as a list of numbers. >My problem is the 2nd and 3rd column of data may touch each by the >minus mark "-" and there are 100000 lines in this block. How can I >do it with Version5.0. I would read the data in using either ReadList["a.file",String] or ReadList["a.file:,Record] This would give you a list of strings. Then mapping StringTake to this list you could extract just those characters that formed a given number and use ToExpression to convert that string to a number. For example, if the first number was always the first three characters, then stringData=ReadList["a.file",String]; data=ToExpression@StringTake[#,3]&/stringData; would put the first column of numbers into data. -- To reply via email subtract one hundred and four