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

Home » Public Forums » archive » Re: compare ascii files, EOF
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
Re: compare ascii files, EOF [message #31644] Mon, 29 July 2002 08:22
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
c7kowo@geogr.uni-jena.de (Wolfgang Koppe) writes:

> Hi,
> I�trying to compare 2 ascii-files with the "where"-fuction to get to
> know which rows are equal. Both files have different lengths. The
> query starts at row 1 and stops at the end of the shorter file. But I
> would like to query till the end of the longer file.
> I�ve tried it with the EOF-fuction, but it doesn�t work.

As Reimar has pointed out, you can use a set-comparison function, like
his, or like my CMSET_OP. However this can be dangerous in the
presence floating point numbers since you will hit precision issues.

I would have said that if your files are in time order, and small
enough, then using a FOR or WHILE loop may be appropriate.
Unfortunately your file2 has values out of time order.

Another possibility is to combine the two files into one array, SORT()
them, and look for pairs of values that are close. You will also have
to maintain a secondary array describing the source of the value (1 or
2). Internally this is what CMSET_OP does.

Good luck,
Craig


--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: compare ascii files, EOF [message #31648 is a reply to message #31644] Mon, 29 July 2002 07:50 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Reimar Bauer wrote:
>
> Wolfgang Koppe wrote:
>>
>> Hi,
>> I�trying to compare 2 ascii-files with the "where"-fuction to get to
>> know which rows are equal. Both files have different lengths. The
>> query starts at row 1 and stops at the end of the shorter file. But I
>> would like to query till the end of the longer file.
>> I�ve tried it with the EOF-fuction, but it doesn�t work.
>>
>> file1 file2
>> 2451823.5034722 2451823.5041666
>> 2451823.5041666 2451823.5173111
>> 2451823.5048611 2451823.5243056
>> 2451823.5055555 2451823.5069444
>> 2451823.5062500 .
>> 2451823.5069444
>> 2451823.5076389
>> 2451823.5083333
>> .
>> .
>> Can you help to query the whole file.
>>
>> thanks.
>> Wolfgang
>
> Dear Wolfgang
>
> you can use our which_indices routine
>
> ;
> ; EXAMPLE:
> ; result=which_indices([10,2,3,20,4,12],[10,20,30])
> ; print,result
> ; 0 3
> ;

Make sure you check for a (difference < precision) rather than an equality though.

paulv

--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC Beer is good.
Ph: (301)763-8000 x7274 My wife.
Fax:(301)763-8545
Re: compare ascii files, EOF [message #31650 is a reply to message #31648] Mon, 29 July 2002 03:53 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Wolfgang Koppe wrote:
>
> Hi,
> I�trying to compare 2 ascii-files with the "where"-fuction to get to
> know which rows are equal. Both files have different lengths. The
> query starts at row 1 and stops at the end of the shorter file. But I
> would like to query till the end of the longer file.
> I�ve tried it with the EOF-fuction, but it doesn�t work.
>
> file1 file2
> 2451823.5034722 2451823.5041666
> 2451823.5041666 2451823.5173111
> 2451823.5048611 2451823.5243056
> 2451823.5055555 2451823.5069444
> 2451823.5062500 .
> 2451823.5069444
> 2451823.5076389
> 2451823.5083333
> .
> .
> Can you help to query the whole file.
>
> thanks.
> Wolfgang

Dear Wolfgang

you can use our which_indices routine

;
; EXAMPLE:
; result=which_indices([10,2,3,20,4,12],[10,20,30])
; print,result
; 0 3
;


http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/download/which_indices.tar.gz


for further routines and licensing please have a look at
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html

regards

Reimar
--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
============================================================ =======
Re: compare ascii files, EOF [message #31651 is a reply to message #31650] Mon, 29 July 2002 03:48 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Wolfgang Koppe wrote:
>
> Hi,
> I�trying to compare 2 ascii-files with the "where"-fuction to get to
> know which rows are equal. Both files have different lengths. The
> query starts at row 1 and stops at the end of the shorter file. But I
> would like to query till the end of the longer file.
> I�ve tried it with the EOF-fuction, but it doesn�t work.
>
> file1 file2
> 2451823.5034722 2451823.5041666
> 2451823.5041666 2451823.5173111
> 2451823.5048611 2451823.5243056
> 2451823.5055555 2451823.5069444
> 2451823.5062500 .
> 2451823.5069444
> 2451823.5076389
> 2451823.5083333
> .
> .
> Can you help to query the whole file.
>
> thanks.
> Wolfgang

Dear Wolfgang

you can use our which_indices routine

;
; EXAMPLE:
; result=which_indices([10,2,3,20,4,12],[10,20,30])
; print,result
; 0 3
;


http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/download/which_indices.tar.gz


for further routines and licensing please have a look at
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html

regards

Reimar
--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
============================================================ =======
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: bizarre number transformation
Next Topic: Trip to Ol' Stomping Grounds

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

Current Time: Mon Oct 20 11:09:16 PDT 2025

Total time taken to generate the page: 2.72011 seconds