pro loadbfile_wc_stor,filename,variablename,err ; this code is used to load bfiles which has comma and gzipped print,'Loading '+filename ;open the data file openr,f,filename,/get_lun,Error=err,/compress if err ne 0 then begin ;check err to see if file was opened print,'!!!WARNING!!!' print,'File does not exist or there are other problems.' print,'Load not executed.' endif else begin first='' readf,f,first ;read first line and figure out how many columns there are first=strtrim(str_sep(strcompress(strtrim(first,2)),','),2) ;string array of 1st line col=n_elements(first) ;no. of columns is no. of elements of string array variablename=fltarr(col,20000);initialize an array to hold data variablename(*,0)=float(first);1st line: convert string array to float dat=fltarr(col) ;temporary float array to hold data as it is read i=1L while not eof(f) do begin ;loop through each file line until eof reached readf,f,dat ;read line of file ;if file is too big discontinue loading, generate message. if i gt 19999L then begin print,'File is longer than 20,000 lines. Need to costomize load program.' variablename=-999. goto,fini endif variablename(*,i)=dat ;load output array i=i+1L endwhile print,'The variable is a '+strtrim(string(col),2)+' column X '+strtrim(string(i),2)+' row array.' ;trim the output array variablename=variablename(*,0:i-1) ;close file and free logical unit number close,f free_lun,f endelse fini: return end