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

Home » Public Forums » archive » Re: Reading complicated ASCII data
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Reading complicated ASCII data [message #71524 is a reply to message #71520] Tue, 29 June 2010 07:13 Go to previous messageGo to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Tone M R wrote:
> Does anyone see a way around these dots?

Use regular expressions to change them to "0.0". I.e. if a "." is not preceded and
followed by a digit, then it becomes "0.0".

Although you could, I wouldn't do the above "preprocessing" in IDL. A scripting language
like ruby/python/perl would be the go; e.g.

#!/usr/bin/env ruby
# Define regular expression for search
re = %r{\s\.\s}
# Inplace edit the file
ARGF.each do |line|
line.gsub!(re,"0.0")
puts(line)
end

I created a file of text from your example containing:

------------------------------------------------------------ -----
[block of not-so-interesting information]

Date Jan Feb Mar Apr May Jun Jul
1 0.5 1.4 . 4.7 . . 0.1
2 0.6 0.3 3.9 . . . .
3 5.8 1.6 4.9 0.1 3.1 3.4 4.4
4 2.0 5.1 1.9 0.2 0.5 6.7 3.3
5 6.8 0.6 9.7 . 2.7 0.8 1.6
... and so forth, for an entire year. - a 13x31 table of floats.

[new block of non-helpful stuff]

[new block of data for another year]
------------------------------------------------------------ ------------
etc..., for a total of ten years.



ran it through the above script like so

$ ruby testit.rb blah.txt

and got the result:

------------------------------------------------------------ -----
[block of not-so-interesting information]

Date Jan Feb Mar Apr May Jun Jul
1 0.5 1.4 0.0 4.7 0.0 0.0 0.1
2 0.6 0.3 3.9 0.0 0.0 0.0 0.0
3 5.8 1.6 4.9 0.1 3.1 3.4 4.4
4 2.0 5.1 1.9 0.2 0.5 6.7 3.3
5 6.8 0.6 9.7 0.0 2.7 0.8 1.6
... and so forth, for an entire year. - a 13x31 table of floats.

[new block of non-helpful stuff]

[new block of data for another year]
------------------------------------------------------------ ------------
etc..., for a total of ten years.


So there are some spacing issues to be ironed out, but works easypeasy.

cheers,

paulv
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: problem is ther in my progam how to solve this problem
Next Topic: Add GSHHS coastline on georeferenced image layers retrieved from MODIS HDF file?

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

Current Time: Wed Oct 08 19:37:09 PDT 2025

Total time taken to generate the page: 0.00448 seconds