comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Extraction from *.txt file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Extraction from *.txt file [message #91252] Tue, 23 June 2015 08:19 Go to next message
d.poreh is currently offline  d.poreh
Messages: 406
Registered: October 2007
Senior Member
Folks,
Hi,
I have many *.txt files like this:

E-SAR IMAGE DATA VOLUME, VERSION 3.1, PRODUCED BY
GERMAN AEROSPACE CENTER (DLR e.V.)
MICROWAVES AND RADAR INSTITUTE
P.O.BOX 11 16
D-82230 WESSLING, GERMANY
Volume created on 11-Dec-2007 16:47:13.00
Copyright (c) 2007 by DLR, all rights reserved.
Suggestions welcome. Please mail to:
RADAR: R. Horn, E-Mail: Ralf.Horn@dlr.de
PROCESSING: R. Scheiber, E-Mail: Rolf.Scheiber@dlr.de
J. Fischer, E-Mail: Jens.Fischer@dlr.de
============================================================ ==================
SCENE-ID: I06AGRSAR0208X1_T01
VOLUME-ID: I06AGRSAR0208X1_T01_GTC_RP-MASTER
DATE OF RAW DATA ACQUISITION: 19-APR-2006
============================================================ ==================
I.)-VOLUME DESCRIPTION
This volume includes the following files (TOC)
...

And I want to extrct line 15 that says :
DATE OF RAW DATA ACQUISITION: 19-APR-2006

And i need just (19-APR-2006).
Any help would be apprecated,
Thank and have a nice SUMMER :)
Cheers,
Dave
Re: Extraction from *.txt file [message #91253 is a reply to message #91252] Tue, 23 June 2015 08:35 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
dave poreh writes:

> I have many *.txt files like this:
>
> ...
>
> And i need just (19-APR-2006).
> Any help would be apprecated,

What line have you managed to read so far?

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Extraction from *.txt file [message #91254 is a reply to message #91253] Tue, 23 June 2015 08:47 Go to previous messageGo to next message
d.poreh is currently offline  d.poreh
Messages: 406
Registered: October 2007
Senior Member
On Tuesday, June 23, 2015 at 8:05:22 PM UTC+4:30, David Fanning wrote:
> dave poreh writes:
>
>> I have many *.txt files like this:
>>
>> ...
>>
>> And i need just (19-APR-2006).
>> Any help would be apprecated,
>
> What line have you managed to read so far?
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

Hi David,
There are some lines like:

PIXEL SPACING NORTH (DETECTED) [m]: 2.0000000
PIXEL SPACING NORTH (SLC) [m]: 2.0000000
PIXEL SPACING EAST (DETECTED) [m]: 2.0000000
PIXEL SPACING EAST (SLC) [m]: 2.0000000
MINIMUM EASTING DETECTED: 382938.00
MINIMUM EASTING SLC: 382938.00
MINIMUM NORTHING DETECTED: 5982280.0
MINIMUM NORTHING SLC: 5982280.0
MAXIMUM EASTING DETECTED: 391510.00
MAXIMUM EASTING SLC: 391510.00
MAXIMUM NORTHING DETECTED: 5985510.0
MAXIMUM NORTHING SLC: 5985510.0

That I could read and retrive the data SO FAR :)
Cheers,
Dave
Re: Extraction from *.txt file [message #91255 is a reply to message #91254] Tue, 23 June 2015 09:58 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
dave poreh writes:

>
> On Tuesday, June 23, 2015 at 8:05:22 PM UTC+4:30, David Fanning wrote:
>> dave poreh writes:
>>
>>> I have many *.txt files like this:
>>>
>>> ...
>>>
>>> And i need just (19-APR-2006).
>>> Any help would be apprecated,
>>
>> What line have you managed to read so far?
>>
>> Cheers,
>>
>> David
>> --
>> David Fanning, Ph.D.
>> Fanning Software Consulting, Inc.
>> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
>
> Hi David,
> There are some lines like:
>
> PIXEL SPACING NORTH (DETECTED) [m]: 2.0000000
> PIXEL SPACING NORTH (SLC) [m]: 2.0000000
> PIXEL SPACING EAST (DETECTED) [m]: 2.0000000
> PIXEL SPACING EAST (SLC) [m]: 2.0000000
> MINIMUM EASTING DETECTED: 382938.00
> MINIMUM EASTING SLC: 382938.00
> MINIMUM NORTHING DETECTED: 5982280.0
> MINIMUM NORTHING SLC: 5982280.0
> MAXIMUM EASTING DETECTED: 391510.00
> MAXIMUM EASTING SLC: 391510.00
> MAXIMUM NORTHING DETECTED: 5985510.0
> MAXIMUM NORTHING SLC: 5985510.0
>
> That I could read and retrive the data SO FAR :)

Well, keep going! You are almost to the line you want! How are you going
to tell when you get there?

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Extraction from *.txt file [message #91256 is a reply to message #91252] Tue, 23 June 2015 10:49 Go to previous messageGo to next message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Hello,

I created a three pretend files based on your snippet below, and changed
the dates.

I would use something other than IDL as a preprocessor on your text files.

Rather than IDL, I would use grep:

$ grep "DATE OF RAW DATA ACQUISITION" *.txt
blah1.txt:DATE OF RAW DATA ACQUISITION: 19-APR-2006
blah2.txt:DATE OF RAW DATA ACQUISITION: 20-APR-2006
blah3.txt:DATE OF RAW DATA ACQUISITION: 21-APR-2006

If you just want the dates:

$ grep "DATE OF RAW DATA ACQUISITION" *.txt | cut -d":" -f3
19-APR-2006
20-APR-2006
21-APR-2006

If you want filenames and dates:

$ grep "DATE OF RAW DATA ACQUISITION" *.txt | cut -d":" -f1,3
blah1.txt: 19-APR-2006
blah2.txt: 20-APR-2006
blah3.txt: 21-APR-2006

You could use this to save to a "control" file, doing something like:

$ grep "DATE OF ...." *.txt | cut -d":" -f1,3 > ctrl.dat

And you can read "ctrl.dat" simply in IDL -- since you want every line,
right?

cheers,

paulv


On 06/23/15 11:19, dave poreh wrote:
> Folks,
> Hi,
> I have many *.txt files like this:
>
> E-SAR IMAGE DATA VOLUME, VERSION 3.1, PRODUCED BY
> GERMAN AEROSPACE CENTER (DLR e.V.)
> MICROWAVES AND RADAR INSTITUTE
> P.O.BOX 11 16
> D-82230 WESSLING, GERMANY
> Volume created on 11-Dec-2007 16:47:13.00
> Copyright (c) 2007 by DLR, all rights reserved.
> Suggestions welcome. Please mail to:
> RADAR: R. Horn, E-Mail: Ralf.Horn@dlr.de
> PROCESSING: R. Scheiber, E-Mail: Rolf.Scheiber@dlr.de
> J. Fischer, E-Mail: Jens.Fischer@dlr.de
> ============================================================ ==================
> SCENE-ID: I06AGRSAR0208X1_T01
> VOLUME-ID: I06AGRSAR0208X1_T01_GTC_RP-MASTER
> DATE OF RAW DATA ACQUISITION: 19-APR-2006
> ============================================================ ==================
> I.)-VOLUME DESCRIPTION
> This volume includes the following files (TOC)
> ...
>
> And I want to extrct line 15 that says :
> DATE OF RAW DATA ACQUISITION: 19-APR-2006
>
> And i need just (19-APR-2006).
> Any help would be apprecated,
> Thank and have a nice SUMMER :)
> Cheers,
> Dave
>
Re: Extraction from *.txt file [message #91259 is a reply to message #91252] Wed, 24 June 2015 00:01 Go to previous messageGo to next message
d.poreh is currently offline  d.poreh
Messages: 406
Registered: October 2007
Senior Member
On Wednesday, June 24, 2015 at 2:34:07 AM UTC+4:30, alx wrote:
> Le mardi 23 juin 2015 19:49:53 UTC+2, Paul van Delst a écrit :
>> Hello,
>>
>> I created a three pretend files based on your snippet below, and changed
>> the dates.
>>
>> I would use something other than IDL as a preprocessor on your text files.
>>
>> Rather than IDL, I would use grep:
>>
>> $ grep "DATE OF RAW DATA ACQUISITION" *.txt
>> blah1.txt:DATE OF RAW DATA ACQUISITION: 19-APR-2006
>> blah2.txt:DATE OF RAW DATA ACQUISITION: 20-APR-2006
>> blah3.txt:DATE OF RAW DATA ACQUISITION: 21-APR-2006
>>
>> If you just want the dates:
>>
>> $ grep "DATE OF RAW DATA ACQUISITION" *.txt | cut -d":" -f3
>> 19-APR-2006
>> 20-APR-2006
>> 21-APR-2006
>>
>> If you want filenames and dates:
>>
>> $ grep "DATE OF RAW DATA ACQUISITION" *.txt | cut -d":" -f1,3
>> blah1.txt: 19-APR-2006
>> blah2.txt: 20-APR-2006
>> blah3.txt: 21-APR-2006
>>
>> You could use this to save to a "control" file, doing something like:
>>
>> $ grep "DATE OF ...." *.txt | cut -d":" -f1,3 > ctrl.dat
>>
>> And you can read "ctrl.dat" simply in IDL -- since you want every line,
>> right?
>>
>> cheers,
>>
>> paulv
>>
>>
>> On 06/23/15 11:19, dave poreh wrote:
>>> Folks,
>>> Hi,
>>> I have many *.txt files like this:
>>>
>>> E-SAR IMAGE DATA VOLUME, VERSION 3.1, PRODUCED BY
>>> GERMAN AEROSPACE CENTER (DLR e.V.)
>>> MICROWAVES AND RADAR INSTITUTE
>>> P.O.BOX 11 16
>>> D-82230 WESSLING, GERMANY
>>> Volume created on 11-Dec-2007 16:47:13.00
>>> Copyright (c) 2007 by DLR, all rights reserved.
>>> Suggestions welcome. Please mail to:
>>> RADAR: R. Horn, E-Mail: Ralf.Horn@dlr.de
>>> PROCESSING: R. Scheiber, E-Mail: Rolf.Scheiber@dlr.de
>>> J. Fischer, E-Mail: Jens.Fischer@dlr.de
>>> ============================================================ ==================
>>> SCENE-ID: I06AGRSAR0208X1_T01
>>> VOLUME-ID: I06AGRSAR0208X1_T01_GTC_RP-MASTER
>>> DATE OF RAW DATA ACQUISITION: 19-APR-2006
>>> ============================================================ ==================
>>> I.)-VOLUME DESCRIPTION
>>> This volume includes the following files (TOC)
>>> ...
>>>
>>> And I want to extrct line 15 that says :
>>> DATE OF RAW DATA ACQUISITION: 19-APR-2006
>>>
>>> And i need just (19-APR-2006).
>>> Any help would be apprecated,
>>> Thank and have a nice SUMMER :)
>>> Cheers,
>>> Dave
>>>
>
> If you are using Windows, you don't have "grep". But you still have IDL !
>
> Assume yourfile is a string containing the name of your text file.
> First, you can put its content into a string array:
>
> IDL> s = strarr(File_Lines(yourfile))
> IDL> openR, lun, /GET_LUN, yourfile & readF, lun, s & Free_LUN, lun
>
> Then, to achieve your goal:
>
> Find the line containing the desired signature:
>
> IDL> w = where(Strpos(s, 'DATE OF RAW DATA ACQUISITION') ge 0))
>
> Extract the relevant data:
>
> IDL> data = (StrSplit(s[w], ':', /EXTRACT))[-1]
>
> If you want to have result converted to binary:
>
> IDL> data = 0.0
> IDL> reads, (StrSplit(s[w], ':', /EXTRACT))[-1], data
>
> Hoping that this can help,
> alx.
Thanks guys :). That is brilant Alx; working like a charm. Yes I do not have "grep", so i prefer IDL ways :).
Cheers,
OT...Re: Extraction from *.txt file [message #91262 is a reply to message #91252] Wed, 24 June 2015 07:23 Go to previous messageGo to next message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
On 06/23/15 18:04, alx wrote:
>
> If you are using Windows, you don't have "grep". But you still have IDL !
>

Windows doesn't have grep (or something like it) ?!?!?

(Jaw drops open. Shut mouth with hand)

This will (may) only be funny to folks familiar with Seinfeld but, to
paraphrase Elaine: I don't know how you guys walk around with those things.

:oD

cheers,

paulv
Re: OT...Re: Extraction from *.txt file [message #91263 is a reply to message #91262] Wed, 24 June 2015 07:27 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Paul van Delst writes:

>
> On 06/23/15 18:04, alx wrote:
>>
>> If you are using Windows, you don't have "grep". But you still have IDL !
>>
>
> Windows doesn't have grep (or something like it) ?!?!?
>
> (Jaw drops open. Shut mouth with hand)
>
> This will (may) only be funny to folks familiar with Seinfeld but, to
> paraphrase Elaine: I don't know how you guys walk around with those things.
>
> :oD

I've used Windows Grep for years. Works great.

http://www.wingrep.com/download.htm

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: OT...Re: Extraction from *.txt file [message #91264 is a reply to message #91263] Wed, 24 June 2015 14:14 Go to previous message
lecacheux.alain is currently offline  lecacheux.alain
Messages: 325
Registered: January 2008
Senior Member
Le mercredi 24 juin 2015 16:27:07 UTC+2, David Fanning a écrit :
> Paul van Delst writes:
>
>>
>> On 06/23/15 18:04, alx wrote:
>>>
>>> If you are using Windows, you don't have "grep". But you still have IDL !
>>>
>>
>> Windows doesn't have grep (or something like it) ?!?!?
>>
>> (Jaw drops open. Shut mouth with hand)
>>
>> This will (may) only be funny to folks familiar with Seinfeld but, to
>> paraphrase Elaine: I don't know how you guys walk around with those things.
>>
>> :oD
>
> I've used Windows Grep for years. Works great.
>
> http://www.wingrep.com/download.htm
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")


Grep exists in Windows. Great !
Also in MSDOS, I guess.
But, frankly speaking, I did not know because, those days, I never need for it ...
alx.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Feature request: printing very long arrays
Next Topic: BYTSCL function

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 09:20:29 PDT 2025

Total time taken to generate the page: 0.00500 seconds