Fetching the file with space in filename

Highlighted
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.

Twelve 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?
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

Twelve 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*)
Twelve 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*).

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Downloads and Trials

Test drive Talend's enterprise products.

Downloads