Skip to Content
avatar image
Former Member

Import CSV file dynamically in a procedure SAP HANA

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Nov 14, 2017 at 03:28 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • 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!

    Add comment
    10|10000 characters needed characters exceeded

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

    <or>

    • Re-export files with comma as delimiter.
    Add comment
    10|10000 characters needed characters exceeded

  • Dec 01, 2017 at 07:32 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded