[resolved] Swap Data in text file

Highlighted
Four Stars

[resolved] Swap Data in text file

Hi,

 I have a text file that I need to change some data in. The file is x12 formatted file but there is only one segment where I need to move the data. This is a sample of one of the lines:

W01*1*EA*111101001985*VN*C4041C 058A P042 S*29.50*29.50**1**0.00*106480002




I need to swap 111101001985 and 106480002. This line is just delimited by an *.  I can't just read it in as a delimited file as there are other lines in the file that have different formatted text. But any lines that start with W01 I want to do this with.
I think I could do it by using tFileInputRaw and connect that with tjavarow. I'm just not sure the code to put in. Then the other lines I would just write back out to the text file as is.
Any help would be appreciated.


Accepted Solutions
Highlighted
Community Manager

Re: [resolved] Swap Data in text file

Hi 
You can use tFileInputFullRow to read the file line by line, and then filter the lines that starts with "W01" and process these lines.
tFileInputFullRow--main--tFilterRow--main--....
                                                   --reject--...
BRS
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

View solution in original post


All Replies
Highlighted
Community Manager

Re: [resolved] Swap Data in text file

Hi 
You can use tFileInputFullRow to read the file line by line, and then filter the lines that starts with "W01" and process these lines.
tFileInputFullRow--main--tFilterRow--main--....
                                                   --reject--...
BRS
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

View solution in original post

Highlighted
Four Stars

Re: [resolved] Swap Data in text file

Thanks. That helped me get the issue solved.

2019 GARTNER 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

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog