Skip to content
Julian Halliwell edited this page May 8, 2017 · 14 revisions

Return a CFML query object from CSV data (either a string or a file containing CSV data).

csvToQuery( csv, filepath[, firstRowIsHeader[, trim[, delimiter ] ] ] )

Required arguments

  • csv string: the data in CSV format OR
  • filepath string: full file system path of a file containing CSV data

Optional arguments

  • firstRowIsHeader boolean default=false: whether the first line of the CSV contains the column names to use in the query
  • trim boolean default=true: whether white space should be removed from the beginning and end of the CSV string (usually desirable to prevent blank rows being added to the end of the query)
  • delimiter string default=",": the single delimiter used in the CSV to separate the fields

Example

spreadsheet = New spreadsheet();
savecontent variable="csv"{
  WriteOutput( '
Name,Phone
"Frumpo McNugget",12345
' );
};
data = spreadsheet.csvToQuery( csv=csv, firstRowIsHeader=true );

Clone this wiki locally