Created 12-14-2020 06:57 AM
Hi there.
I would like to concat all the values of a repetitive key and put all of them as the value of one unique key with the same name.
The input would be like:
{
"main": "id;Date;Time;Trigger_time_open;Trigger_time_close;Door;Door_Cycle;Motor_current;Motor_voltage;DLS;DCS;Inclinometer;Temperature"
},
{
"main": "00000;2020/7/18;04:53:37.211;04:53:37.524;04:53:51.847;01;36688;12.062867;0.000000;-1;-1;12.078014;26.303200"
},
{
"main": "00001;;04:53:37.212;;;;;12.064088;0.000000;-1;-1;;"
}
An the output something like:
{
"main":"id;Date;Time;Trigger_time_open;Trigger_time_close;Door;Door_Cycle;Motor_current;Motor_voltage;DLS;DCS;Inclinometer;Temperature00000;2020/7/18;04:53:37.211;04:53:37.524;04:53:51.847;01;36688;12.062867;0.000000;-1;-1;12.078014;26.30320000001;;04:53:37.212;;;;;12.064088;0.000000;-1;-1;;"
}
I have been trying with join and concat, but I'm completely new to Jolt transformations, and it's been a pain to find the way.
As you can see, the result would be a big string containing all the records of a csv.
thank you very much for your help.
Created 12-14-2020 08:12 AM
I got the result using:
[
{
"operation": "shift",
"spec": {
"*": {
"main": "main.[&1]"
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"main": "=join('\n',@(1,main))"
}
}
]
Not sure whether is the best approach. But it works. Thanks a lot
Created 12-14-2020 07:21 AM
with this :
[
{
"operation": "shift",
"spec": {
"*": {
"main": "main"
}
}
}
]
I am able to get this:
{
"main" : [ "id;Date;Time;Trigger_time_open;Trigger_time_close;Door;Door_Cycle;Motor_current;Motor_voltage;DLS;DCS;Inclinometer;Temperature", "00000;2020/7/18;04:53:37.211;04:53:37.524;04:53:51.847;01;36688;12.062867;0.000000;-1;-1;12.078014;26.303200", "00001;;04:53:37.212;;;;;12.064088;0.000000;-1;-1;;" ]
}
But what I need is a main element with all the values concatenated with a \n among them
Created 12-14-2020 08:12 AM
I got the result using:
[
{
"operation": "shift",
"spec": {
"*": {
"main": "main.[&1]"
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"main": "=join('\n',@(1,main))"
}
}
]
Not sure whether is the best approach. But it works. Thanks a lot
Created 12-14-2020 08:21 AM
Thanks for posting your solution!
I was just trying too but I think your input data has to be set to an array for this. Am I getting right?
Created 12-15-2020 12:44 AM