How to filter lines with Regex from an input directory and write to Kafka?

Five Stars

How to filter lines with Regex from an input directory and write to Kafka?

I'd like to read files from a directory and write the lines in each file that satisfy a regular expression into Kafka. I need to include the file name in the line written to Kafka. For e.g. if the file is /exp/talend/first.txt and it has a line first then the line to Kafka should be /exp/talend/first.txt:first. Now I use the tFileList component and connect it to tFileInputRegex component with an iterate connection. However when I give the context variable for the file name as "file Name Stream: ((String)globalMap.get("tFileList_1_CURRENT_FILEPATH"))" the red error on the regex component does not go away and the task does not run. The documentation for the tFileList shows this as a global variable during flow execution. 

Moderator

Re: How to filter lines with Regex from an input directory and write to Kafka?

Hello,

Would you mins posting your current job design screenshots on forum which will be helpful for us to address your issue?

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Five Stars

Re: How to filter lines with Regex from an input directory and write to Kafka?

Attached are the screen shots, very simple work flow.

Ten Stars

Re: How to filter lines with Regex from an input directory and write to Kafka?

Im not sure but you are escaping \" in your regex, make sure you escape properly because a \ slash is also an escape char in regex, so ... \\\ , three slashes to escape one slash, not 100% sure, but google a bit on escaping double quotes in java and regex

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