csv_parse
Parses a CSV file.
csv_parse
(in string_session_input any,
in callback_sp_name varchar,
inout callback_user_data varchar,
[in from_line integer],
[in to_line integer],
[in opts any]);
Description
Parses string session containing CSV data and then calls stored procedure
by given callback_sp_name parameter. The call back will be invoked for lines
between from_line and to_line argument's values.
The default from/to is 0/null which means from begining to end.
The callback function must take three arguments: the vector which contains
parsed csv row, the line number, inout the callback_user_data.
Parameters
string_session_input –
String session containing CSV data will be parsed as CSV where it will
insert into the table specified as table_name the lines between from_line and to_line offsets.
callback_sp_name –
The name of the stored procedure.
callback_user_data –
The user data.
from_line –
Default - 0, This means counted from the begining.
to_line –
Default - null, This means counted to the end.
opts –
Default - null. The opts paramater is used to specify the delimiter
and quote it should look like this:
vector ('csv-delimiter', self.delim, 'csv-quote', self.quot)
Examples
create procedure y_csv_cb (inout r any, in inx int, inout cbd any)
{
if (cbd is null)
cbd := vector ();
cbd := vector_concat (cbd, vector (r));
}
;
....
h := null;
csv_parse (ss, 'DB.DBA.y_csv_cb', h, 0, 10);
....