How to add the spaces between the columns of the output

Hi Team,

I want to add the customized spaces between each column of the table below and want to get the same PO number to next missing values too.


Attaching the KNIME workflow also please suggest me how to do it.

Automation-IDOC–Singapore.knwf (379.9 KB)
The number of spaces I want to give between each column is as below
image

Please let me know for further information.

Thanks,
Subramanyam Kinthada.

Hi @Subramanyam

It appears to me that you are rushing things a bit. I see that you copy pasted the solution from @bruno29a in another area of your workflow where it is working properly already.

KNIME is pretty clear in this case as to why it’s not working for the second data flow.

  • For the Column Appender: Table 1 is shorter than the longest table. Corresponding columns were filled using missing values. This is because you took out the Transpose node before.

image

  • You are now dealing with multiple columns rather than just one as in the other case. Switch the String Manipulation node with the String Manipulation (Multiple Column) node and use join($$CURRENTCOLUMN$$, padLeft("", $spaces$, " ")) with enforced exclusion of the spaces column.

You should be able to keep the rest as is to get a similar output result.

2 Likes

Hi @ArjenEX ,

Thanks for your suggestion,

The main issue is with the PO number presented only in one row and I need to get the same PO number in complete column.


could you please tell me how can I get it.

Thanks in advance.

Subramanyam Kinthada.

Try the missing value node. Select that column and “previous value”.

2 Likes

Hi @ArjenEX,

I have used the column expression node and used Join function with the spaces as below.
join(column(“split_0”)," “,column(“PO Number”),” “,column(“combined column”),” "
,column(“split_5”)," “,
column(“new column”),” “,
column(“new column1”),” “,
column(“new column2”),” “,
column(“new column3”),” ",
column(“Shipment code”))

Now I need to write the output table details to Text file. for that I used CSV Writer File node but the output is not writing as expected into text file as below.
pod.txt (722 Bytes)

Automation-IDOC–Singapore.knwf (379.7 KB)

Please help me in resolving the issue.

thanks in advance
subramanyam kinthada.

That looks like the output that I would have expected to see from your join formula. (All columns are joined into a single text column with a space in between them) What is your output goal?

Hi @iCFO ,

how the output of the column filter the same should come in the Text file while using the CSV writer node. But it the spaces are not as expected in the output. Please find the attached output file.
pod.txt (722 Bytes)

Please suggest me if any other nodes are there to create the text file.

thanks in advance
subramanyam kinthada

I can’t really see the difference on my cell… Perhaps it is just a character code difference that shows a larger space? This is an option in the CSV writer.

Encoding

  • File Encoding

To write a CSV file with a different encoding, you can select a character set in this tab (UTF-8, UTF-16, etc.), or specify any other encoding supported by your Java VM. The default value uses the default encoding of the Java VM, which may depend on the locale or the Java property “file.encoding”

You can also try skipping the join function in your column expression node and using this to insert a space between columns.

  • Replace column separator with

Specify a replacement for the value used as a column separator. Used only if the never option is selected for Quote values.

Why are you jumping from one solution to another? You have one that didn’t work, then I and @iCFO gave you some pointers to get to work and now you’re jumping to a completely different one. Which is obviously flawed as well because you hardcode the space in the join()

In this (and also the other) topic I have a feeling you are not actually reading what people mention to you. Why would I invest my time again into helping you when it just falls on deaf man ears?

/rant off.

1 Like

Yep. This was very confusing. I think that he was trying to insert a certain count of spaces between each column that he had described in the top table, but then just wrote a join formula with a single space between each column.

If you want to go that route, then just put the right number of spaces into your join function?

Really hard to tell what you are trying to do and why you are going about it differently than the suggestions.

Hi @ArjenEX @iCFO ,

I have tried both your suggestions mentioned above and the suggestion provided by ICFO for missing value node is successful.
and I have tried the string manipulation (multiple column) node but I am not getting the expected result.
Hence I moved to join() hard coded and it is successful but while writing as text file as output to my local using CSV writer node the result is not as expected the spaces which I have given are completely changing.

My sincere apologies if I missed something from your suggestions.

Thanks,
Subramanyam Kinthada

What is the expected result that you are aiming for? Can you manually write out one row so that it matches what you are trying to do?

Hi @iCFO ,

My expected output is as below in a single line. Please find the attached output.
10 4502617106 200308566781720418 3800 IT 0.00 IT 0 0 2003085667

final utput.txt (2.1 KB)
Thanks,
Subramanyam Kinthada

And that is just a single space in between each column?

@iCFO

When I pasted it is like how I expected but when I submitted it changed to one space between the columns. Please kindly review the attached final output file
final utput.txt (2.1 KB)

thanks,
Subramanyam Kinthada

Automation-IDOC–Singapore.knwf (377.1 KB)

It took some setting adjustments, but working.

It was clear what the issue was once I was able to open your workflow.

1 Like

FYI - The CSV output node required an empty quote character, then under Advanced Settings / Quote Values I changed it to “If Needed”. This maintained the additional spaces in your string in the txt output file.

Edit - I noticed that there was a “space” in the quote character instead of a blank. It is fixed below.
Automation-IDOC–Singapore.knwf (377.1 KB)

1 Like

Hi @iCFO ,

Its working fine. thanks a lot for your support.

Thanks,
Subramanyam Kinthada.

1 Like

It’s ok, I know this feeling too sometimes :slight_smile:

It can indeed by quite frustrating!

Here here :smiley:
image

Or if you love cats :joy:

Cheers :slight_smile:

1 Like