Solved

Split a column into two

  • 13 February 2022
  • 8 replies
  • 30 views

Badge

Newbi question, if i have a table where i want to splitt a collumn into two how woud I do that.

 

Existing format

Column a , Column B, Column C

Index,0,0

2022-01,100,245

2022-02,101, 145

2022-03, 90, 200

North,0,0

2022-02,23, 123

2022-03,35,250

South,0,0

2022-01,87,100

 

Now I need to isolate the column a and the heading values, Index, North, South and make a new column

Column a , Column B, Column C, New Column

Index,0,0,index

2022-01,100,245, index

2022-02,101, 145, index

2022-03, 90, 200, index

North,0,0, north

2022-02,23, 123, north

2022-03,35,250, North

South,0,0, South

2022-01,87,100, South

 

The source can be an excel or a db table. Target is a db table

How do I do that?

icon

Best answer by chrisatsafe 14 February 2022, 23:05

View original

8 replies

Badge +2

Hi @danketil​ ,

 

Just to make sure I have this right, essentially you want to take the value from Column A and set it on the following columns until it changes from Index to North/South/etc?

2022-02-14_13-46-23 If so, you can get this done using the adjacent feature handling feature in the AttributeManager. Since adjacent feature handling requires the attribute to already exist, you'll first need to use an AttributeCreator or AttributeManager to create column D. Then, in an AttributeManager set the number of prior features to 1 and set the following conditional value for column D.

2022-02-14_14-02-57I've attached a sample workspace and dataset in case that helps. From there, you can write it out to whatever format you'd like. Simply type the name of the format or use the add writer button and connect it to the AttributeManager.

 

Output:

2022-02-14_14-06-45

Userlevel 4
Badge +30

Hi @danketil​ ,

 

Just to make sure I have this right, essentially you want to take the value from Column A and set it on the following columns until it changes from Index to North/South/etc?

2022-02-14_13-46-23 If so, you can get this done using the adjacent feature handling feature in the AttributeManager. Since adjacent feature handling requires the attribute to already exist, you'll first need to use an AttributeCreator or AttributeManager to create column D. Then, in an AttributeManager set the number of prior features to 1 and set the following conditional value for column D.

2022-02-14_14-02-57I've attached a sample workspace and dataset in case that helps. From there, you can write it out to whatever format you'd like. Simply type the name of the format or use the add writer button and connect it to the AttributeManager.

 

Output:

2022-02-14_14-06-45

Great Job @chrisatsafe​ 

Badge

Hi @danketil​ ,

 

Just to make sure I have this right, essentially you want to take the value from Column A and set it on the following columns until it changes from Index to North/South/etc?

2022-02-14_13-46-23 If so, you can get this done using the adjacent feature handling feature in the AttributeManager. Since adjacent feature handling requires the attribute to already exist, you'll first need to use an AttributeCreator or AttributeManager to create column D. Then, in an AttributeManager set the number of prior features to 1 and set the following conditional value for column D.

2022-02-14_14-02-57I've attached a sample workspace and dataset in case that helps. From there, you can write it out to whatever format you'd like. Simply type the name of the format or use the add writer button and connect it to the AttributeManager.

 

Output:

2022-02-14_14-06-45

chrisatsafe

Sorry for my late reply, yes that is correct

Badge

I tried your solution but it only works for the first row, it does not replicate the value Index for all rows

Userlevel 2
Badge +17

I tried your solution but it only works for the first row, it does not replicate the value Index for all rows

Hi @danketil​ , I got this table from @chrisatsafe​ 's workspace. Isn't this your desired one?​

result

Badge

imageThis is how the model now looks

and below you find the dataset from query

imageAs you can see it is correct for the first row but it does not apply teh rule for the rest of the rows

Userlevel 2
Badge +17

imageThis is how the model now looks

and below you find the dataset from query

imageAs you can see it is correct for the first row but it does not apply teh rule for the rest of the rows

Your conditional value setting seems to be wrong. I think it should look like this.conditional-value-setting

Badge

Thanks I figured out what I did wrong. Now it works.

Reply