- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Convert TXT to JSON using Schema counting chars
- Labels:
-
Apache NiFi
Created 04-19-2023 12:29 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
with this topic i need a clue.
I have a text based data, this is an example row:
CA20230405112337BOL006057 20230405V1260 2023021000409I 311003000102504
CA20230405112337BOL006057 20230405V1260 2023021000509I 311003000102504
I need to convert to json but:
1 - i need to remove all spaces in between
2 - i need to separate fields with a separator in order to create a schema and make a conversion
Example:
CA;20230405;bla bla bla
CA;20230405;bla bla bla
How can i achieve this?
Is there any other way to do that?
Many Thabks
Created 04-20-2023 12:02 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi @Ray82,
Assuming that you have a way to identify where you need to add your ";", you can easily use NiFi's Expression Language to add it. More details are available here: https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html.
At first sight, if you identify a pattern, you can use any function with replace in order to replace your white space with semicolon. Next, to add the semicolon between your characters, you can use an regex, based on your pattern. In terms of processors, you have ReplaceText, UpdateAttribute, UpdateRecord, etc .... so you have plenty to choose from 🙂
Created 04-20-2023 12:02 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi @Ray82,
Assuming that you have a way to identify where you need to add your ";", you can easily use NiFi's Expression Language to add it. More details are available here: https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html.
At first sight, if you identify a pattern, you can use any function with replace in order to replace your white space with semicolon. Next, to add the semicolon between your characters, you can use an regex, based on your pattern. In terms of processors, you have ReplaceText, UpdateAttribute, UpdateRecord, etc .... so you have plenty to choose from 🙂
