ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/JSOC/proj/globalhs/scripts/idl/readx.pro
Revision: 1.1
Committed: Thu Oct 4 00:11:43 2012 UTC (10 years, 11 months ago) by tplarson
Branch: MAIN
CVS Tags: Ver_8-8, Ver_8-11, Ver_8-2, Ver_8-10, Ver_8-0, Ver_8-1, Ver_8-6, Ver_LATEST, Ver_8-4, Ver_9-41, Ver_8-3, Ver_8-5, Ver_8-12, Ver_8-7, Ver_9-5, Ver_9-4, Ver_9-3, Ver_9-2, Ver_9-1, Ver_9-0, HEAD
Log Message:
utility function for reading ascii tables

File Contents

# Content
1 function readx,filename,ncol=ncol,nlin=nlin,status=status
2
3 status=0
4 nlin=0L
5 spawn,'wc -l '+filename,help
6 reads,help,nlin
7 if (nlin eq 0) then begin
8 status=1
9 print,'error: file '+filename+' is empty'
10 return,0
11 endif
12 ntot=0L
13 spawn,'wc -w '+filename,help
14 reads,help,ntot
15 if ((ntot mod nlin) eq 0) then begin
16 ncol=ntot/nlin
17 q=dblarr(ncol,nlin)
18 openr,37,filename
19 readf,37,q
20 close,37
21 endif else begin
22 status=2
23 print,'error: readx cannot read from file '+filename
24 endelse
25
26 return,q
27
28 end
29