Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Oracle Apex - PL/SQL - Apex_data_parser reading csv files

Jasper TanglibApr 14 2021

Hi,
In Oracle 20.2, I have a code that reads the csv file uploaded into wwv_flow_files. This will display the contents of a csv file which I would then use to insert into a table.
My code:
SELECT col001 RN, col002 INST_ID, col003 NAME, col004 VALUE, col005 DISPLAY_VALUE
FROM wwv_flow_files f,
TABLE ( apex_data_parser.parse(
p_content => f.blob_content,
p_store_profile_to_collection => 'FILE_PARSER_COLLECTION',
p_file_name => f.filename,
p_skip_rows => 2 ) ) p
WHERE name LIKE '%all_parameters.csv'

I'm expecting that the csv file is read like this (it is separated by a delimiter of 3 characters <,>). This is what it looks like when I open my csv file through notepad(.txt):
image.png
But using my code, the output of the csv file read is like this. The 4th and 5th column should actually be in only 1 column:
image.pngIf I open the csv file using its .csv extension, it looks like this. It is detecting the comma (,) as something else and splitting the values into different columns.
image.png

I tried adding the p_csv_delimiter in my parameter but it just made the data worse.
SELECT col001 RN, col002 INST_ID, col003 NAME, col004 VALUE, col005 DISPLAY_VALUE
FROM wwv_flow_files f,
TABLE ( apex_data_parser.parse(
p_content => f.blob_content,
p_store_profile_to_collection => 'FILE_PARSER_COLLECTION',
p_file_name => f.filename,
p_skip_rows => 2,
p_csv_row_delimiter => '<,>' ) ) p
WHERE name LIKE '%all_parameters.csv'
image.png
How can I have apex_data_parser.parse read my CSV file in the format it would have when opened in .txt extension.

Any ideas or suggestions as appreciated,
-Jazz

This post has been answered by jariola on Apr 14 2021
Jump to Answer

Comments

Post Details

Added on Apr 14 2021
5 comments
2,716 views