Fixed length output

Hello,

Is it possible to create a fixed field-length output file?
This would mean that column 1 has a fixed length of 32, column 2 has a fixed length of 20, and so on.

I saw there is a ticket fixed width output that was using string manipulation, but I couldn’t get it to work. Could anybody explain how to set this up?

Thank you.

Hello @rutger,

and welcome to kNIME Community!

If you have one column and would like to split it to multiple ones with fixed length I would use Cell Splitter By Position node. If that doesn’t help can you provide some input data and expected output to figure out what are you exactly dealing with?

Br,
Ivan

1 Like

Hello Ivan,

I just found out about the string manipulation step padRight(str, size) which performs this task for me.
The only issue I have is that only 1 column is possible, where I would need about 20 different columns of different sizes.

So what I would need will look like this:
$PARTNO$ = padRight($PARTNO$, 32);
$DESCRIPTION$ = padRight($DESCRIPTION$, 20);
$ATACHAPTER$ = padRight($ATACHAPTER$, 5);

Which should give an output like so:

PARTNO1 DESCRIPTION1 ATAC1
PARTNO2 DESCRIPTION2 ATAC2

Do you know of any solution to this?

kr,

Rutger

There should be spaces in between this. Read - as space

PARTNO1------------------------DESCRIPTION1------------------ATAC1
PARTNO2------------------------DESCRIPTION2------------------ATAC2

You should be able to do this using the Column Expressions node, with one expression per column you need to adjust. So, lots of expressions, but at least it would all fit in one node. Then you could use a Column Combiner afterward to build a single line, like this:

2021-03-17 13_56_39-KNIME Analytics Platform

Will that work?

1 Like

Thank you Scott,

This is exactly what I was looking for!

Kind regards,

Rutger

2 Likes

You could use a column loop and use the current column variable to do that in combination with scotts workflow
br

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.