unfortunately the above given function didn’t helped me.
how can we give the empty spaces between the columns.
For Example I want to give 4 empty spaces between the first and second column, 10 empty spaces between second and third column.
current output consists of same empty spaces between all the columns.
Hi @Subramanyam , how are you reading the file? I mean, what’s the delimiter for the columns? Or is it just 1 column for the whole row?
And also, can you share the file so we can have an idea of what you are talking about and so we can have some data to test our solutions?
Also, please be advised that it’s a community forum, meaning that people will help when they can, and it’s usually slower over the weekend.
What exactly have you tried from @mlauber71 suggestions that you said did not work? Did you try his workflow? It looks like the forum might not display properly the expression - as you can see, the replace statement in the screenshot has the proper spaces, but the one pasted in the forum only have 1 space from search and replace. If you copied from the forum, then it’s normal that you did not replace anything, since it search for 1 space and replaced with 1 space.
The Regex solution that he suggested is also a valid alternative. Did you try it?
Yes it is only one row in the table and we are extracting it out using the CSV writer node. now we require the empty spaces between the columns should be customized.
The empty space between first and second should be 4 and between second and third columns should be 11 and so on.
we have tried the formula provided by mlauber for each column but we didn’t received the output as expected.
Hi @Subramanyam sorry, but you have not answered any of my questions, and I still do not understand your data.
I asked if you were reading the whole line as 1 column or not, or at least if you could tell me what the delimiter was.
If you did not understand what I was asking, that is why I asked if you could share the file.
I am pretty sure I can help you, but I just don’t know how your data is being presented in Knime - basically I have no starting point. Can you at least show me how the data is shown in Knime?
With regards to your latest screenshot, I’m not sure what you are trying to do there. The expression that you are using says to replace 1 space with 4 spaces, meaning replace any spaces that you have x4 (1 space will become 4 spaces, 2 spaces will become 8 spaces since each of the 2 spaces will be replaced by 4 spaces each, 3 spaces will become 12 spaces, 4 spaces will become 16 spaces, etc). Is this what you want?
@Subramanyam hoping not to undercut any efforts by the great @bruno29a I have tried to put something together just for the fun of it. Not really sure this would make sense in a real world business task. But alas it can be done. Replace any number of blanks with a fixed number per column and bring them back together.
I might have gotten carried away somewhat - so if someone comes up with a better solution or it turns out this is not what is needed … so be it …
Using CSV Writer node we exported to local as .txt file but didnt achieved the expected output because of the empty spaces. We are using empty spaces as delimiters.
Current output having same number of spaces between all columns.
Yes, We wanna apply the same to our data to get the expected output.
We have tried the replace function but unable to get the expected output.
replace(column(“first”)," “,” ") function we used.
Hi @Subramanyam , thank you so much for the additional info, now we’re getting somewhere.
So basically, I’ve come up with this method:
The idea is to set the delimiters between each column to 10 spaces, except between the first and second columns. Therefore, I first manually join the first and second columns with 4 spaces between them, making them become 1 column, and then join it as a column with the rest with 10 spaces between each.
Thanks for the above method. but my requirement is not the constant empty spaces between all the columns
first and second column ----4 spaces
second and third ------10 spaces
third and fourth ------ 4 spaces
fourth and fifth ------ 12 spaces
fifth and sixth ------ 5 spaces
sixth and seventh ----- 11 spaces
eight and ninth ----- 11 spaces
ninth and tenth ----- 117 spaces
So please kindly suggest the method to achieve the above requirement.
If you would take a look you would find that with my suggested approach you could just configure how many spaces you want to have between the individual columns. Maybe you give it a try
I have achieved 90% of the output. I am able to join the last column with 117 empty spaces between the columns and the result occurred in KNIME output but not in text file.
KNIME Output:
Hi @Subramanyam , well I went with what you originally wrote and showed in your very first post
and all I needed to know after that was how the input data of what you showed was.
Based on what you are explaining now, it’s a totally different approach that’s needed. It’s not the same requirements! It’s a complete redo in the end. Why do most people do that?
I always say this: “Help us help you. The more details/info you provide, the more precise the solution will be”. It serves no purpose rushing and leaving key information out. If anything, it’s a liability to do so.
You are lucky that this is an interesting challenge enough for me to not walk away from it.
@mlauber71 : No need to use a loop to generate the spaces. You can use padding (padLeft() or padRight()) to generate the spaces
This is what I used: join($Row0$, padLeft("", $spaces$, " "))