Fetching the file with space in filename

Five Stars

Fetching the file with space in filename

I want to load an excel file to database.Source File name will be like Test08232018.xlsx. Name of the file followed by current date. Sometimes there will be space between Filename and data. Job has to fetch fetch the file correctly even if it having space or not having the space.

Eleven Stars

Re: Fetching the file with space in filename

where is your problem?
fileName can contain space.

Francois Denis

Tag as "solved" for others! Kudos to thanks!

Nine Stars

Re: Fetching the file with space in filename

Do you want a regular expression sort of functionality to search for your files which matches your criteria and then load to database?
Highlighted
Five Stars

Re: Fetching the file with space in filename

yes. but how to implement regular expression in the file path.

Five Stars

Re: Fetching the file with space in filename

Sometimes file name contains space between name and date and sometimes it won't

Eleven Stars

Re: Fetching the file with space in filename

use tFileList, to list all files
then use Iterate on TFileInputExcel to load each file into db.
Use (String)globalMap.get("tFileList1_CURRENTFILEPATH") as fileName.
Regards

Francois Denis

Tag as "solved" for others! Kudos to thanks!

Five Stars

Re: Fetching the file with space in filename

I have two Excel files with different schema. Both of them has tobe loaded
into separate tables.
Eg:
First file name - TestReport08232018.xlsx
Second file name - Test08232018.xlsx

For loading first file, i am using tFileList.
Inside tFileInputExcel in path, I put filepath+"Test
report"+Talenddate.getDate("MMddyyyy")+".xlsx"

But how to load the second file. How to give path.sometimes space will come
between Test and date.
Nine Stars

Re: Fetching the file with space in filename

A regular expression match like this -

"Test(.*)"

would make sure that you are fetching all the files start with Test

Five Stars

Re: Fetching the file with space in filename

Regular expression for space is \s. I already tried (\s*). I am receiving
an error like invalid escape character.
Nine Stars

Re: Fetching the file with space in filename

You need to use - (\\s*)
Eleven Stars

Re: Fetching the file with space in filename

tFileList List all your file.
for each file (iteration) file name is in (String)globalMap.get("tFileList1_CURRENTFILE") and check the name it may define tale name.
read data using tFileInputExcel you can get fileName full path in (String)globalMap.get("tFileList1_CURRENTFILE").
tFileList give you file name and path for each file you have to use iterate link then your tFileInputExcel will be run for each file.
Regards,

Francois Denis

Tag as "solved" for others! Kudos to thanks!

Five Stars

Re: Fetching the file with space in filename

I am receiving error like Zip File is closed, while trying to use regular expression (\\s*).

What’s New for Talend Spring ’19

Join us live for a sneak peek!

Sign up now

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch

Downloads and Trials

Test drive Talend's enterprise products.

Downloads

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Download