Re: Writing a modified .txt file issue [message #85381 is a reply to message #85380] |
Mon, 29 July 2013 19:18   |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
Hmm, I just cut and pasted your code and got the expected output structure corresponding to the input file. The only change I had to make was to define Ncolumns which isn't defined in your code snippet. Perhaps you had an incorrect value of Ncolumns stored somewhere?
A few words here about READCOL. There are dozens of IDL programs to read ASCII files, and READCOL is certainly not the fastest in computer speed. But I think it requires the least number of brain cells. Here is the READCOL method to read the data file:
IDL> readcol, 'test.dat', hole_id, vfrom, vto, pr_1, pr_2,f='a'
Note that (1) one doesn't need to predefine any of the variables. (2) One needs to specify the column to be read as a string, but no specification is needed for the floating point columns (3) One doesn't need to worry about the header line (any line not meeting the specified format is ignored). Also, READCOL can handle missing columns with the use of the /PRESERVE_NULL keyword.
--Wayne
>
> Here are my results when I run the program:
>
>
>
> This is the result structure:
>
> { 2006/1 0.000000 0.000000 0.000000 6.00000}
>
> { 2006/1 0.000000 0.000000 0.000000 12.2500}
>
> { 2006/2A 0.000000 0.000000 0.000000 2.00000}
>
> { 2006/2A 0.000000 0.000000 0.000000 5.90000}
>
> { 2006/2A 0.000000 0.000000 0.000000 8.70000}
>
>
>
> What am I doing wrong?
>
>
>
> 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.")
|
|
|