Re: filtering data data in .txt [message #92992 is a reply to message #92990] |
Tue, 05 April 2016 08:16  |
Jeremy Bailin
Messages: 618 Registered: April 2008
|
Senior Member |
|
|
On Tuesday, April 5, 2016 at 10:51:53 AM UTC-4, omar ali wrote:
> بتاريخ الثلاثاء، 5 أبريل، 2016 4:21:39 م UTC+2، كتب Jeremy Bailin:
>> On Tuesday, April 5, 2016 at 10:12:24 AM UTC-4, omar ali wrote:
>>> Hi,
>>> I need to filter out the the rows having -9.999 values from the following data. I read the text file with opnr command but unfortunately, date and time are gone.
>>>
>>> Example of the file is below:
>>>
>>> 9/20/2007 10:00:00 1.88
>>> 9/20/2007 11:00:00 1.88
>>> 9/20/2007 12:00:00 1.88
>>> 9/20/2007 13:00:00 1.88
>>> 9/20/2007 14:00:00 1.88
>>> 9/20/2007 15:00:00 1.88
>>> 9/20/2007 16:00:00 1.86
>>> 9/20/2007 17:00:00 1.86
>>> 9/20/2007 18:00:00 1.83
>>> 9/20/2007 19:00:00 -9.999
>>> 9/20/2007 20:00:00 -9.999
>>> 9/20/2007 21:00:00 -9.999
>>> 9/20/2007 22:00:00 -9.999
>>> 9/20/2007 23:00:00 -9.999
>>> 9/21/2007 0:00:00 -9.999
>>> 9/21/2007 1:00:00 -9.999
>>> 9/21/2007 2:00:00 -9.999
>>> 9/21/2007 3:00:00 -9.999
>>> 9/21/2007 4:00:00 -9.999
>>> 9/21/2007 5:00:00 -9.999
>>> 9/21/2007 6:00:00 -9.999
>>> 9/21/2007 7:00:00 -9.999
>>> 9/21/2007 8:00:00 -9.999
>>> 9/21/2007 9:00:00 -9.999
>>> 9/21/2007 10:00:00 1.81
>>> 9/21/2007 11:00:00 1.81
>>> 9/21/2007 12:00:00 1.81
>>> 9/21/2007 13:00:00 1.83
>>> 9/21/2007 14:00:00 1.83
>>
>> I would recommend using WHERE.
>>
>> -Jeremy.
>
> the problem is not using where. actually, it is the format of the first and secound columns. I do not know how to read and write such format. I usually a text with the following command which is not appropriate since it save the data into float array.
>
> Thanks
>
> Code for reading txt file
> --------------------------
> asc_org="D:\data\file.txt"
> openr,8,asc_org
> r_org=fltarr(1,78840) ; change based on the dimension of the txt file
> readf,8,r_org
> close,8
You might want to use something like READ_ASCII with ASCII_TEMPLATE. Or alternatively, read them all in as strings and parse it yourself line by line.
-Jeremy.
|
|
|