[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading tab delimited string data



Andy Loughe wrote:
> 
> Hello,
> 
> I have some output from a MySQL dump that looks like this...
> 
> id      date    height  coverage        yy      yn      ny      nn
> 1388    2000-07-01      all     all     114     404     240     28452
> 1388    2000-07-01      all     low     114     404     240     28452
> 1388    2000-07-01      high    all     114     404     240     28452
> 1388    2000-07-01      all     all     114     404     240     28452
> 
> I get the data into IDL via this command...
> 
> spawn, 'mysql < sql_script.sql', data
> IDL> help, data
> DATA       STRING  = Array[5]  ; 5 rows of string data (tabs inserted).
> 
> Basically, I am working with tab delimited data with a varying number
> of columns and a varying number of rows, depending upon the sql query.
> 
> I am able to store the data from each column into a separate IDL vector,
> id=[ ]  date=[ ]  height=[ ] , etc. but the approach is to LOOP
> through all rows, do a str_sep(row, string(9B)), and then direct the
> result into the proper index of the IDL vector.
> 
> Looping through all the rows and manipulating each line of string data
> can't be the fastest approach.  Can someone suggest a faster method?
> 
> I thought of ASSOC, and also wondered about str_sep on arrays,
> or maybe some of the new str routines.  Any thoughts?
> 
> Your kind suggestions are appreciated.
> 

Just a thought...
If you have many rows and not so many cols make MySQL do the work
IDL> spawn, 'mysql < get_id.sql', id
IDL> spawn, 'mysql < get_date.sql', date
...

-- 
Ivan Zimine                   |   ivan.zimine@physics.unige.ch
Dpt. of Radiology             |   (+41 22) 372 70 70
Geneva University Hospitals   |