Question

I want to manipulate a large text file, which is coming as TEXT and want to use smooks to manipulate it. The text file contains large number of lines. And from each line, i have to split the characters and get information out of that.

Eg: i do following in java;

row.substring(0, 4) 
row.substring(4, 64) 

I have to convert the text content to CSV file.

  • Can we do exact same string manipulation in smooks too? (that is in smooks configuration can i do that?) I believe i can use Fixed Length processing for that?

  • How to add IF ELSE condition in smooks configuration? Like in java;

    if (row.length() == 900) { //DO }else(){ //DO }

Was it helpful?

Solution

We can do string manipulation using fixed length reader[1]. but still i do not find a way to do condition check.

Eg: if /else

[1]http://www.smooks.org/mediawiki/index.php?title=V1.4:Smooks_v1.4_User_Guide#XML

OTHER TIPS

If the format does not fit the flatfile reader, then you might be able to use the regex reader: https://github.com/smooks/smooks/tree/v1.5.1/smooks-examples/flatfile-to-xml-regex/

As for the conditional stuff... you really need to bind the data fragments into a Java model of some sort (real or virtual) and then conditionally process those fragments by either adding elements on the visitors being applied, or process the fragments by routing them to another process that processes them in parallel, which is a far better way of processing a huge data stream.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top