Forum Discussion
This also works and seems a little easier to understand. Instead of searching for the indexes of the open and close parenthesis and using a substring, it just removes everything that isn’t a numeric value. Great solution provided by nsingam, but in the spirit of offering you options, I thought I would share this one with you too. Definitely there are more than 1 way to skin a cat (horrible expression).
$[‘betroffene IT Systeme’].map(x => x.replace(/[^0-9]/g, ‘’))
Thank you for your answer, much appreciated. That I haven’t tought about that also. Because I always only need the numbers.
Regards
Jens
- tstack8 years agoFormer Employee
Indeed, there’s a Pivot snap, but that does the opposite of what you’re looking to do. Until such a snap exists, you can do this using a GroupByN snap and the expression language. If you add a GroupByN snap with a “Group Size” of zero, it will collect all of the incoming data into a single document. You can then follow that up with a Mapper that has this expression:
{}.extend($group.map(x => [x.Category, x.DataType]))
The extend() method will construct a new object containing the key/value pairs returned by the
$group.map()
call.Here’s a screenshot:
Here’s an export of this pipeline:
TransposeExample_2018_08_15.slp (6.8 KB)
- virender_prajap8 years agoNew Contributor III
Thanks Team!
It is working fine. 😄- vsunilbabu6 years agoNew Contributor II
Hello everybody,
Can someone help me with exactly the opposite.
to
Also, in my challenge, the names of columns and number of columns will change(dynamic).
Thanks in advance,
Sunil
- stephenknilans8 years agoContributor
Believe it or not, I had the SAME exact problem. I don’t believe there IS a snap to fix this, BUT, you can use the script snap. That is what I did. AND, though I didn’t write it to be neat. If you tell it you are using a python program, you can pivotdata.py.txt (1.6 KB)
use my script. I was a dreamer, and my dream didn’t work. You might want to change the line:in_doc[“_”+fieldsr[i]]=fields[i]
to
in_doc[fieldsr[i]]=fields[i]
- virender_prajap8 years agoNew Contributor III
Thanks Stephen! 🙂
I’ll try this approach as well.
Related Content
- 2 years ago
- 9 months ago
- 3 years ago
- 4 years ago