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

Home » Public Forums » archive » Re: read_ascii for many rows / possible to create automatic names for variables
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: read_ascii for many rows / possible to create automatic names for variables [message #57314 is a reply to message #57153] Wed, 05 December 2007 09:47 Go to previous messageGo to previous message
britta.mey is currently offline  britta.mey
Messages: 14
Registered: August 2007
Junior Member
On Dec 5, 6:15 pm, David Fanning <n...@dfanning.com> wrote:
> Britta writes:
>> Thank you, the file is on its way.
>
> Ah, well, ain't that interesting!
>
> The problem here is that while *most* of your columns
> are separated by blank characters, two of your columns
> are separated by tabs. What this basically means is that
> you should find a gun and shoot the person who created
> this data file. :-)
>
> What is happening is that I used a blank character as
> the separator for calculating the number of columns in
> the file, and because of the two tabs, I come up two
> columns short in the calculation. I calculate 1030 and
> there are really 1032. Thus, my columns are totally
> messed up, and I never read all the data in the file.
>
> So, since these data files are probably identical from one
> run to the next, you could probably just use the number 1032
> for the number of columns and the code would work perfectly.
>
> The other alternative (besides shooting the programmer,
> I mean) is to use a regular expression as the column
> separator in StrSplit. As you are a beginner, and as this
> is something even I don't understand, we will leave it
> to our betters to fill us in on how THIS can be done. :-)
>
> My best guess is that it is something like this:
>
> parts = StrSplit(line, '[ ' + String(9B) + ']+', /REGEX, /EXTRACT)
> cols = N_Elements(parts)
>
> Hope that helps. I haven't see *this* problem before. :-)
>
> Cheers,
>
> David
>
> P.S. It looks to me like I got that expression right from the
> quick test I just ran.
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

Great, thank's a lot. This works. Could you please short explain what
you have done? Or please tell me, if this is correct, what I
understood...

parts = StrSplit(line, '[ ' + String(9B) + ']+', /REGEX, /EXTRACT)

Here you separate the string of the first line into substrings (in the
previous version you told IDL with (.., ' ',..) that a blank charakter
is the separator, correct?), and the part '[ ' + String(9B) + ']+', /
REGEX, means that the pattern of the ascii file contains not only
blank characters but any combination of blank characters and tabs. Am
I right up to here?
So IDL moves forward starting from one column until the binary code is
different from the code of a blank character or a tab and "knows" that
there is the next column.

I wish you a nice day (for me it's time to leave off work).

Cheers,

Britta
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: array operations and memory consumption
Next Topic: pson + !p.multi + xyouts

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

Current Time: Fri Oct 10 17:06:32 PDT 2025

Total time taken to generate the page: 0.79561 seconds