问题
The issue i am facing is that even the data in the CSV file also getting separated if the value consists of ,
(comma)
I am using shell script connect to oracle using the sql plus and spooling the data in the CSV file
In the CSV the colsep ,
(comma) is working fine to separate columns but the data also getting separated.
for example if the value of the company name is (Southern textiles,LICO ) In that case even SOuttheren textiles is in one column and LICO is moving to another column and thee remaining data is getting changed since the comma value separated.
Please help me in the below code i have used in my script is
set feedback off trimspool on;
set pagesize 50000
set serveroutput on
set underline off
set termout off
set feedback off
set colsep " , "
set HEADING ON
set tab off
set trimspool on
set linesize 2000
set trimout on;
column company_name format a10
回答1:
set colsep " , "
It is best not to surround the separator with spaces, because those spaces should be seen as part of the field by the parser (see RFC 4180).
If your fields contain ,
another separator (like ;
or |
) could be used, but the proper way is to surround those fields with "
(probably a parameter to the generator). If the field itself has a "
inside it should be escaped with another "
.
回答2:
SQLPlus has CSV formatting. Just do
Set markup csv on
来源:https://stackoverflow.com/questions/61407396/sql-plus-output-is-not-coming-in-proper-csv-format-if-we-use-the-colsep