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

Reading tab delimited string data


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.

Andrew Loughe =====================================================
NOAA/OAR/FSL/AD   R/FS5  |  email: loughe@fsl.noaa.gov
325 Broadway             |  wwweb: www-ad.fsl.noaa.gov/users/loughe
Boulder, CO  80305-3328  |  phone: 303-497-6211   fax: 303-497-6301