'Snowflake mapping columns names from CSV files

I have a table in Snowflake that have 24 columns in it. And I also have a CSV files in the S3 bucket with the changing number of columns. Sometimes it can be 4 columns and sometimes it can be 24 columns etc. I need also map the names of the CSV files columns to the name of the Snowflake table columns. Is there any way how to do it?



Solution 1:[1]

You would need to pre-process your CSV file to bring it to a more consistent format as your target table.

You can extract the column header and generate a COPY command mapping those columns into your table.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Clark Perucho