cancel
Showing results for 
Search instead for 
Did you mean: 

Import from CSV SQL Function with Double Quotes

0 Kudos

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?

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member89972
Active Contributor
0 Kudos

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

TuncayKaraca
Active Contributor
0 Kudos

Hi Raj,

It seems you have to escape the double quotes with a backslash.

eg: \"stage\",

0 Kudos

I can't modify the given CSV File as it being generated from the User Comments and these Key Words will be used for text analysis

0 Kudos

We haven't installed SDI in our platform. ;-(

lbreddemann
Active Contributor
0 Kudos

“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.