Name
get_csv_row — This function takes a string_session containing CSV data, parses a row and returns a vector with field values.
Synopsis
get_csv_row
(
|
in ses any , |
in delim char , | |
in
quote
char
) ; |
Description
This function takes a string_session containing CSV data, parses a row and returns a vector with field values.
Calling the function in a loop with same input will parse file line by line.
The function is also making a basic prediction of field types for varchar, integer and float values, so the result data may have one of these. If come other datatype is need to be produced the caller can convert the string using the BIF like cast sprintf_inverse and so on.
Parameters
ses
string_session containing CSV data
delim
Optional argument to handle tab, space delimited etc. formats.
quote
Optional argument to handle tab, space delimited etc. formats.
Return Types
Returns a vector with field values.
Examples
Example 24.123. Simple Use
The following example prints on the Virtuoso Server console the CSV columns names:
SQL>create procedure my_csv (in file_name varchar) { dbg_obj_print(get_csv_row(file_open('tmp/MyContacts.csv'))); } ; Done. -- 10 msec. SQL>select my_csv('tmp/MyContacts.csv'); callret VARCHAR ______________________ 0 1 Rows. -- 10 msec. -- and on the Virtuoso Server console will be shown: ('First Name;Last Name;Middle Name;Name;Nickname;E-mail Address;Home Street;Home City;Home Postal Code;Home State;Home Country/Region;Home Phone;Home Fax;Mobile Phone;Personal Web Page;Business Street;Business City;Business Postal Code;Business State;Business Country/Region;Business Web Page;Busines s Phone;Business Fax;Pager;Company;Job Title;Department;Office Location;Notes' )