One Star

How to get file name

I want to upload a csv file into sql server table. I need get the file name and use the file name in the job. The file name pattern is "nl_accounts_yyyy.csv". I want to exact the 'yyyy' and store it in table. how i can do that?
One Star

Re: How to get file name

you can use a tfilelist for that, even if you iterate only on one file
put a tfilelist on your job plug iterations on on a tjavarow
in the tjavarow press <ctrl>+<space> it will propose a list of variables choose the one you want from tfilelist
One Star mpa
One Star

Re: How to get file name

I would do the following.
tFileList --> tFixedFlowOutput --> tMssqlOutput
Following code in tFixedFlowedInput:

If you want to load the file in your database and have the year in an extra column you can do the following:
tFileList --> tFileinputdelimited--> tMap --> tMssqlOutput
In the extra column in the output part of the tMap you can put the same code from the tfixedflowinput. Every record will then have the year of the file in an extra column.
See attached screenshots.
One Star

Re: How to get file name

thanks for reply!