Skip to main content
Question

Extract values from a column

  • March 24, 2020
  • 2 replies
  • 34 views

parashari
Forum|alt.badge.img+2

I know there are already posts about this, but couldn't find much info about it.

I have a column in csv with multiple fields and values in the same column:

col1

 

{ "21" : 80.0, "81" : null, "21" : 100.0, "21" : 60.0 }

 

{ "21" : 60.0, "21" : 80.0, "81" : null, "21" : 80.0, "21" : 100.0, "21" : 100.0, "21" : 60.0 }

 

 

Representation-

21- max speed

81- max weight

The occurrence of fields:1st time- Car, 2nd time- Bus, 3rd time-Truck

Max Speed (Car)

 

Max Weight(Car)

 

Max Speed (Bus)

 

Max Speed (Truck)

 

Max Speed(D Truck)

 

Max Speed (B Truck)

 

80

 

null

 

100

 

60

 

null

 

null

 

60

 

null

 

80

 

100

 

100

 

100

 

 

Attaching the csv.

I am able to use AttribuleSplitter, SubstringExtractor and putting them in fields, but the values are not in uniformity. Any suggestions?

Thanks in advance.

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.

2 replies

ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • March 24, 2020

If I've understood correctly, i would use a string searcher with some regex to pull into a list all the speed elements and simply rename these, then repeat with the weight elements if required

e.g. regex in stringsearcher

(?<="21" : )[0-9]+\.[0-9]

then rename list elements to attribute

0684Q00000ArKqrQAF.png


takashi
Celebrity
  • 7843 replies
  • March 24, 2020

I read your sample data with CSV reader, this is the result. As you can see there are some unexpected representations such as 82, 105, and 4. How do you translate them?

Could you please explain the rules for mapping all the elements  shown below to desired fields?

col1
"82" : null, "21" : 60.0, "21" : 100.0, "21" : 80.0
"21" : 30.0, "21" : 80.0, "81" : null, "105" : 390.0, "21" : 60.0, "21" : 100.0
"21" : 30.0
"21" : 80.0, "21" : 100.0, "21" : 60.0
"4" : null
"21" : 50.0
"21" : 80.0, "81" : null, "105" : 390.0, "21" : 60.0, "21" : 60.0, "21" : 70.0, "21" : 100.0
"4" : null
"21" : 30.0, "21" : 80.0, "81" : null, "105" : 390.0, "21" : 60.0, "21" : 100.0
"4" : null
"21" : 80.0, "21" : 100.0, "4" : null, "21" : 60.0
"21" : 80.0, "81" : null, "105" : 390.0, "21" : 60.0, "21" : 60.0, "21" : 70.0, "21" : 100.0