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!

Why APEX_DATA_PARSER trim the whitespaces in csv files?

ronald_2017Nov 3 2023 — edited Nov 3 2023

Hello All,

I read very good articles about APEX_DATA_PARSER. It is very useful package. However, why it trim whitespaces from csv files. So, how to prevent this? I need to insert the original data in the file.

https://blogs.oracle.com/apex/post/super-easy-csv-xlsx-json-or-xml-parsing-about-the-apex-data-parser-package

https://blogs.oracle.com/apex/post/easy-xlsx-parser-just-with-sql-and-plsql

with
 function clob2blob(AClob CLOB) 
 return BLOB 
 is
  Result BLOB;
  o1 integer;
  o2 integer;
  c integer;
  w integer;
begin
  o1 := 1;
  o2 := 1;
  c := 0;
  w := 0;
  DBMS_LOB.CreateTemporary(Result, true);
  DBMS_LOB.ConvertToBlob(Result, AClob, length(AClob), o1, o2, 0, c, w);
  return(Result);
end;
q1 as (
select clob2blob(to_clob(
'C1;C2;C3;C4
1;TEST ;TEST 2 ;5
2; TEST ;TEST 2 ;4
3; TEST TEST5; TEST TEST 2 ;4')) c1 
from dual
)
select 
line_number, 
col001, col002, col003, col004, col005, col006, col007, col008, col009, col010, col011, col012, col013, col014, col015, 
col016, col017, col018, col019, col020, col021, col022, col023, col024, col025, col026, col027, col028, col029, col030, 
col031, col032, col033, col034, col035, col036, col037, col038, col039, col040, col041, col042, col043, col044, col045, 
col046, col047, col048, col049, col050, col051, col052, col053, col054, col055, col056, col057, col058, col059 
from (select * from q1) t1, 
     table(apex_data_parser.parse(p_content   => t1.c1,
                                  p_file_name => 'temp.csv',
                                  p_skip_rows => 1
                                 ))
/

Thanks in advance

Comments
Post Details
Added on Nov 3 2023
8 comments
430 views