Skip to Content
0

Import CSV file dynamically in a procedure SAP HANA

Nov 14, 2017 at 01:42 PM

385

avatar image
Former Member

Hi All,

I am trying to import some data from a CSV file into HANA table as below,

IMPORT FROM CSV FILE 'C:/Users/Desktop/zone1.csv'
INTO "SCM"."ZONE_TEMP" 
WITH RECORD DELIMITED BY '\n'
     FIELD DELIMITED BY ',';

Below error is being displayed when I execute the above code,

Could not execute 'IMPORT FROM CSV FILE 'C:/Users/Desktop/zone1.csv' INTO "SCM"."ZONE_TEMP" WITH RECORD ...' 
SAP DBTech JDBC: [2]: general error: Cannot open CSV file, C:/Users/Desktop/zone1.csv

Any suggestions would be appreciated.

Thanks,

Srinivasa Reddy

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Michael Healy
Nov 14, 2017 at 03:28 PM
0

You tried with a "." or a ",". One is a full stop, the other is a comma? You should try it with a comma.

If you're using a comma already then check if there are restrictions on the path that the IMPORT statement is trying to access. See SAP Note https://launchpad.support.sap.com/#/notes/2109565

You could try:

ALTER SYSTEM ALTER CONFIGURATION ('indexserver.ini', 'system') set ('import_export', 'enable_csv_import_path_filter') = 'false' with reconfigure ;

IMPORT FROM CSV FILE'C:/Users/Desktop/zone1.csv'

INTO"SCM"."ZONE_TEMP" 

WITH RECORD DELIMITED 

BY'\n'FIELD DELIMITED 

BY',';

You can also import by using HANA Studio:

File->Import->SAP HANA Content->Data from Local File->Select source file, filed delimiter,header row, set target table schema and name->Finish

You should also check the permissions at OS level if the above doesn't work

Share
10 |10000 characters needed characters left characters exceeded
Margoth Del Rosario Jun 04 at 09:19 PM
-1

Hello,

Im trying to import from csv from a root that it different to the hana server. Something like

IMPORT DATA INTO TABLE "FLUTEPLAYER"."TABLATEMPORAL" FROM 'D:/FPEscenarios/Ruta_Org/sapasiento00001.csv' RECORD DELIMITED BY '\n' FIELD DELIMITED BY ',';

D: disk is in my pc. Can I use a root diferent to hana server???

Thanks you!

Show 2 Share
10 |10000 characters needed characters left characters exceeded

I literally answered your question in my reply to the OP.

0

Thank. Yes, I did not understand before.

0
Michael Healy
Nov 14, 2017 at 03:06 PM
0
  • Write script to change delimiter in existing csv file to "," comma.

<or>

  • Re-export files with comma as delimiter.
Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Michael,

I tried with '.' too. I am still getting the same error.

Any other suggestions ?

Thanks.

0
Former Member

Hi Michael,

I kept the CSV file on Desktop

Path is : 'C:/Users/Desktop/zone1.csv'

This path is correct or not

Thanks

0
Lars Breddemann
Dec 01, 2017 at 07:32 AM
0

The import command is for importing data that is accessible to the HANA server. The path you posted is on the client machine - see how that doesn’t match up?

Either you put the data in a folder that your HANA server can access or use the import option in HANA studio that Michael already mentioned.

Share
10 |10000 characters needed characters left characters exceeded