Read Fixed width Flat file using TOS

Four Stars

Read Fixed width Flat file using TOS

Hi All,

I am trying to read a Fixed Width flat file using tFileInputPositional. However, there are a couple of things that needs to be ensured when the data is red from the source.
i. The trailing spaces for all fields needs to be trimmed.
ii. If the data present in the fields of the file consist only of '*' then we need to read the field data as ''. Whereas if the data consists of characters along with '*' then the data should be read as is. (eg:'****' or '***********' gets read as '' . But 'abc**erf*' gets read as 'abc**erf*')
Please suggest if there is any easier way  of getting this done rather than dealing with each source field individually in a tMap.

Thanks

Community Manager

Re: [resolved] Read Fixed width Flat file using TOS

Hi
For 1, there is a 'trim all column' box option in the advanced setting panel of tFileInputPositional component, this box is checked by default. 
For 2, I think you need to hard code to check and transform the data after reading it from the source file.
----------------------------------------------------------
Talend | Data Agility for Modern Business
Four Stars

Re: [resolved] Read Fixed width Flat file using TOS

Hi,

As suggested I tried using the below expression for point 2:

StringHandling.LEN(StringHandling.EREPLACE(out1.row1,"*","")) > 0 ? Fout1.row1 : "" 

But this gives an error like java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 2.

Please suggest whether its required to put escape characters with '*' like '\\*' to make it work.

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

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download