Home > Blockchain >  Snowflake Copy Into : Is there a Skip Header option but for the end of a file?
Snowflake Copy Into : Is there a Skip Header option but for the end of a file?

Time:12-11

I'm trying to copy a file into a table that has text at the start (think date, etc.) and then text at the end (also like date, "end of data", etc.). The rest of data are separated values that I can use the field delimiter for. I know I can skip headers in the COPY INTO but is there a way to end the COPY INTO at a certain point so that it doesn't try to ingest the end of data text?

CodePudding user response:

You can tell Snowflake to copy the whole file into a table, and ignore errors:

copy into table1
from @stage1
on_error = continue

If the last row of the file is throwing errors, then this will happily import all of the correctly formed rows.

CodePudding user response:

As Felipe suggested, first test your file in VALIDATION_MODE=RETURN_ALL_ERRORS or RETUR_2_ROWS and see how it behaves .Based off that you can decide which option to use.

  • Related