-1

Is it possible to generate the .CSV file with pipe (|) delimiters instead of comma (,) through UTL_FILE package?

Kindly share me how to do if it is possible.

Thanks, Janardhan.

APC
  • 144,005
  • 19
  • 170
  • 281

2 Answers2

2

Sure you can write nearly anything in a csv file ...

declare  
   v_file utl_file.file_type;
begin  

   v_file := utl_file.fopen('DATA_FILE_DIR', 'example2.csv', 'W');
   utl_file.put_line(v_file, 'colid|colstring|colnumber|coldate');  
   utl_file.put_line(v_file, '1|"nothing"|231.12|2019-01-03 23:43:32');
   utl_file.put_line(v_file, '2|"not more"|121|2020-10-05 14:33:15');
   utl_file.FFLUSH(v_file);  
   utl_file.fclose(v_file);  
end;
Thomas Strub
  • 1,275
  • 7
  • 20
  • Thanks Thomas for your inputs. But when i open the CSV file, all the data will be available in a single column. Is it possible to separate the data based on the Pipe delimited? – Janardhan Feb 11 '20 at 14:08
  • 1
    As written from @APC you have to choose how to open the file. But why did you need to write the file with | when you don't know how to open a csv-file? – Thomas Strub Feb 11 '20 at 14:23
2

when i open the CSV file, all the data will be available in a single column Is it possible to separate the data based on the Pipe delimited?

That is a feature of MS Excel, regardless of how the file was produced. What you need to do is

  1. In MS Excel open a new book
  2. From the menu Data > From text
  3. In the Wizard choose Delimited option
  4. On the next step choose Other and put | in the box
  5. Press Finish

Excel will now open your file with multiple columns as defined by the pipes.

APC
  • 144,005
  • 19
  • 170
  • 281