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

Home » Public Forums » archive » TRICKY TASK USING AWK
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: TRICKY TASK USING AWK [message #92793 is a reply to message #92791] Mon, 29 February 2016 09:44 Go to previous messageGo to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On Monday, February 29, 2016 at 11:58:32 AM UTC-5, Sapna Mishra wrote:
> Actually I want to grep a particular column say column 2 from fname[i] and want to save it to fnameo[i] as an output. In IDL I don't know how to read any file having unknown numbers of columns because in READCOL to read file we need to mention a variable for each column in which particular column will get stored.

Here is a short IDL program to read the number of columns in a file, e.g.
ncol = findnumcol('myfile.dat')

function findnumcol, file
; Return the number of columns of data in a file
; Just reads the first line and assume rest of the file
; is the same. Could add code to skip header lines
openr,lun,file,/get_lun
st = ''
readf,lun,st
free_lun,lun
tmp = strsplit(st,count=ncol)
return,ncol
end
[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
Previous Topic: Looping through structures
Next Topic: Segmentation fault (core dumped)

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

Current Time: Fri Oct 10 09:35:11 PDT 2025

Total time taken to generate the page: 0.87593 seconds