x

Loading csv file stored in different folders

hi! We receive data feed from the client every day so the folders are created with datenames like 20160101,20160102 etc. There are five different csv files in each folder and the naming convention is same as the folder like test_20160101.csv,test2_20160101.csv. In this I need to pick only test2 csv files in different folders and load into a sql table.

Appreciate any suggestions Thank you

more ▼

asked Jan 26, 2016 at 05:01 PM in Default

avatar image

apple
770 36 55 64

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

You should be able do this with SSIS. Are the file names consistent? Always test2 (whatever)?Use a ForEach loop to build a collection for the files that you want. The loop will iterate through children folders if you specify it to do so.

This is an older article but still valid:

https://www.simple-talk.com/sql/ssis/ssis-basics-introducing-the-foreach-loop-container/

Hope that helps!

more ▼

answered Jan 26, 2016 at 05:05 PM

avatar image

JohnM
14.2k 3 7 14

Thanks a lot John, I got confused because of the different folders.

Jan 26, 2016 at 07:23 PM apple

Just set the collection for the parent folder and specify "traverse sub-folders" and it'll drive down into the sub-folders. Hope that helps!

Jan 26, 2016 at 07:47 PM JohnM
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x1219

asked: Jan 26, 2016 at 05:01 PM

Seen: 36 times

Last Updated: Jan 26, 2016 at 07:47 PM

Copyright 2017 Redgate Software. Privacy Policy