on 09-20-2018 8:33 PM
Hi,
I have a requirement to automate the Flat File (CSV) from HANA Database into a HANA table.
I'm using the SQL function "IMPORT From CSV File" to upload the data into the table. The command gets executed but only partial data is getting loaded into the table because some of the fields have double quotes(") in their value. I wanted them to be loaded as it is. i.e with Double Quotes. Below is an example of the data set.
bent,No,1,Manifold Lane Failure,og,12/12/2016
"tips,No,1,Manifold Lane Failure,og,12/12/2016
"stage",No,1,Manifold Lane Failure,og,12/12/2016
Below is the command I'm executing to load the file
import from CSV FILE 'XXX/Symptons_Text_Analysis.csv' into "SymptomSearchCriteria" with RECORD DELIMITED BY '\n' FIELD DELIMITED BY ',' OPTIONALLY ENCLOSED BY '"' FAIL ON INVALID DATA;
XXX is the HANA database folder.
Please let me know how can I achieve this. Is IMPORT FROM CSV File a right option?
For bulk load into HANA I used tab separated data file with a control file for import.
Contol file looks like below :
IMPORT DATA INTO TABLE "EXPERIMENT"
FROM '/sapmnt/exports/p2h/experiment.tsv'
RECORD DELIMITED BY '\n'
FIELD DELIMITED BY '\t'
ERROR LOG '/sapmnt/exports/p2h/experiment.err'
This way single or double quotes do not pose a problem.
This is assuming that "tab" \t above is not part of the data.
Actual hdbsql session command will be :
IMPORT FROM CONTROL FILE '/sapmnt/exports/p2h/experiment.ctl';
Where I specify full path to the control file.
Control file has target table + full path to the "tsv" file
HTH
Avinash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raj,
It seems you have to escape the double quotes with a backslash.
eg: \"stage\",
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We haven't installed SDI in our platform. ;-(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
“Is IMPORT FROM CSV File a right option?“
Probably not; for regular, flexible data loading you may want to use SDI, e.g. with the File-adapter.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.