www.openlinksw.com
docs.openlinksw.com

Book Home

Contents
Preface

Virtuoso Functions Guide

Administration
Aggregate Functions
Array Manipulation
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
csv_cols_def
csv_load
csv_load_file
csv_parse
csv_table_def
file_delete
file_dirlist
file_mkdir
file_mkpath
file_open
file_stat
file_to_string
file_to_string_outpu...
file_unlink
get_csv_row
gz_file_open
os_chmod
os_chown
Free Text
Hashing / Cryptographic
LDAP
Locale
Mail
Miscellaneous
Number
Phrases
RDF data
Remote SQL Data Source
Replication
SOAP
SQL
String
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
VAD
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web & Internet
XML
XPATH & XQUERY

Functions Index

get_csv_row

This function takes a string_session containing CSV data, parses a row and returns a vector with field values.
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

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' )