ODBiC Discussion Board


RE: WHILE Loop within an IMPORT loop?, David RIchardson, 11-12-2004

Sorry, you can't use a variable for the column list, but...

by Roger Harris, November 14, 2004 18:48

That command just wasn't coded to expect a variable for the column list (although it probably should have been), but the new version (ODBscript 3.0) has direct support for using the column header line to define the variables. Since it's sort of like SQL SELECT * FROM table, the syntax is like this:

<% IMPORT DELIMITER=",",QUOTED, * from $tempfile$.csv %>
This will get the column list from the first line of the file (they can be quoted, but that's not required) and then begin extracting data starting with the second line.

This version also has an important fix for "true CSV" files: it allows multiple-line data fields, if they are quoted. For example, if you have an address field with an end-of-line character within it (because it's really a two or three line address), that's "legal" in a CSV file as long as the entire field is contained in quotes. (That is, if the last field of a line read from the file begins with a quote but doesn't end with a quote, then the field should actually include the end-of-line character, and the data is continued on the next line. The quoted field is extracted up to an ending quote, even if it's several lines away, and other fields may follow that ending quote.) But the old version didn't handle that case properly because it just took each line read from the file as a single line of data.

Dave, I'll contact you about getting this version to test the "* from file" feature. The code is finished (and I actually use that feature myself now in one of my applications). I'm just trying to finish up the Users Guide changes, and I also want to put up a new site for ODBscript.com before I officially release the new version, but if anyone else wants a pre-release version, let me know.



Replies:


Post Your Reply:

Name   
E-mail  optional
Topic  
Message:

HTTP Link: 
Link text: 

          


Copyright ©1997-2003, Roger Harris. All rights reserved.