Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
218 views
in Technique[技术] by (71.8m points)

python - Snowflake: how to load files through stage from MS Azure using specific pattern?

I need to load files from MS Azure to Snowflake tables on a weekly basis, and I wonder if I can find a more efficient way of doing it

For example, if i want to load the files in this dir:

my_folder/food/20200101.csv 
... 
my_folder/food/20201201.csv

and name of the stage is my_stage

then if i want to load the files for the month of June, the query would be:

select * from @my_stage (pattern => 'my_folder/food/202006.*.csv')

My question is, what if I want to load the files between 11/28/2020 and 12/05/2020?

The current method I am using is to separate the pattern like this:

pattern => 'my_folder/food/2020112[8-9].*.csv|my_folder/food/2020113[0-1].*.csv|my_folder/food/2020120[1-5].*.csv

Is there a way to make it simpler? like using >= and <= in the pattern?

Thanks and please let me know if my question lacks clarity. :)

question from:https://stackoverflow.com/questions/65622872/snowflake-how-to-load-files-through-stage-from-ms-azure-using-specific-pattern

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Inside the PATTERN-clause you can use Regex-expressions. I think using a Regex-expression for a date range may become quite complex and your solution is the simplest one. Maybe also looping over the files may help in your case.

More infos about the PATTERN-clause: https://docs.snowflake.com/en/sql-reference/sql/copy-into-table.html#optional-parameters


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...