Skip to main content
Solved

CSV - update column value with a 0

  • July 26, 2021
  • 5 replies
  • 23 views

zentnerfabian
Contributor
Forum|alt.badge.img+5

Hey guys,

 

I have an CSV file where I have 4 different columns with values (column1 till column4). I'am creating in the attribute manager a new columns (column5) where I connect all the values of the first four columns with a point in between.

 

 

 

For example

 

 

```

column1, column2, column3, column4, column5

1, 2, 3, 4, 1.2.3.4

```

 

 

`column2` has the special that there are numbers from `1` til `99`. I want to put infront all values of `column2` which are from `1` til `9` a `0`, so that it looks like the example. But already two digits numbers should not get a `0`.

 

 

 

For example

 

 

```

column1, column2, column3, column4, column5

1, 02, 3, 4, 1.02.3.4

 

3, 65, 5, 9, 3.65.5.9

```

 

How can I manage this? Has anybody a clue? Or could somebody help me please?

 

Thanks in advance!

 

Have a good day!

 

Cheers,

 

Fabian

Best answer by hkingsbury

Hi Fabian, you can use the StringFormatter before the AttributeManager. Have the format string as '02d'

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

5 replies

hkingsbury
Celebrity
Forum|alt.badge.img+65
  • Celebrity
  • Best Answer
  • July 26, 2021

Hi Fabian, you can use the StringFormatter before the AttributeManager. Have the format string as '02d'


zentnerfabian
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • July 27, 2021

Hi hkingsbury,

thank you for your answer. I will try it today!


geomancer
Evangelist
Forum|alt.badge.img+60
  • Evangelist
  • July 27, 2021

Alternatively you can use @PadLeft when defining column5 in the AttributeManager.

@Value(column1).@PadLeft(@Value(column2),2,0).@Value(column3).@Value(column4)

 


zentnerfabian
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • July 27, 2021

@hkingsbury​ it works really well! thanks a lot!


zentnerfabian
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • July 27, 2021

Alternatively you can use @PadLeft when defining column5 in the AttributeManager.

@Value(column1).@PadLeft(@Value(column2),2,0).@Value(column3).@Value(column4)

 

thank you @geomancer​ this option worked also!