Count number of fields in a CSV file record
687520Nov 1 2011 — edited Nov 2 2011Hello,
Here is my problem. I need to open a CSV file on a directory and count the number of fields in a record. I can easily read the first record using UTL_FILE package, something like:
UTL_FILE.fopen (s_remote_dir, s_csv_file, 'R', 32767);
UTL_FILE.get_line (input_file, input_buffer);
then I count the number of commas in the buffer in order to get no. of fields:
IF input_buffer IS NOT NULL THEN
n := <function that counts number of commas in a string, input_buffer>
END IF;
However, this method will not work if a comma is present inside a field, i.e:
127763, "TRA account", 1001, 34, _"1007 main St., apt. 798"_
(last field contains a comma)
Please advise.
Regards,
M.R.