4everMe
4everMe

Reputation: 57

unable to load csv file into snowflake with the COPY INTO command

End of record reached while expected to parse column '"VEGETABLE_DETAILS_PLANT_HEIGHT"["HIGH_END_OF_RANGE":5]'

File 'veg_plant_height.csv', line 8, character 14 Row 3, column "VEGETABLE_DETAILS_PLANT_HEIGHT"["HIGH_END_OF_RANGE":5] If you would like to continue loading when an error is encountered, use other values such as 'SKIP_FILE' or 'CONTINUE' for the ON_ERROR option. For more information on loading options, please run 'info loading_data' in a SQL client.

this is my table

create or replace table VEGETABLE_DETAILS_PLANT_HEIGHT ( 
   PLANT_NAME text(7), 
   VEG_HEIGHT_CODE text(1), 
   UNIT_OF_MEASURE text(2),
   LOW_END_OF_RANGE number(2),
   HIGH_END_OF_RANGE number(2)
   ); 

and the COPY INTO command I used

copy into vegetable_details_plant_height
from @like_a_window_into_an_s3_bucket
files = ( 'veg_plant_height.csv')
file_format = ( format_name=VEG_CHALLENGE_CC );

and the csv file https://uni-lab-files.s3.us-west-2.amazonaws.com/veg_plant_height.csv

Upvotes: 2

Views: 4740

Answers (3)

Michał Waciński
Michał Waciński

Reputation: 1

As you can see in csv file data in one column is in "" and the names are separated by , so u need to use that FIELD_OPTIONALLY_ENCLOSED_BY = '"' type option

Upvotes: 0

Sriga
Sriga

Reputation: 1321

The table has 5 columns but source file consist values for four columns due to this copy command returns the error. In order to resolve the issue you can modified the copy command as mentioned below:

copy into vegetable_details_plant_height(PLANT_NAME, UNIT_OF_MEASURE, LOW_END_OF_RANGE, HIGH_END_OF_RANGE)
from (select $1, $2, $3, $4 from @like_a_window_into_an_s3_bucket)
files = ( 'veg_plant_height.csv') file_format = ( format_name=VEG_CHALLENGE_CC );

Upvotes: 1

Eric Lin
Eric Lin

Reputation: 1530

The error "End of record reached while expected to parse column" means Snowflake detected there were less than expected columns when processing the current row.

Please review your CSV file and make sure each row has correct number of columns. The error said on line 8.

Upvotes: 1

Related Questions