Hi there.
I need help, I need to extract a lot of data from a text that chatgpt gives me in JSON format.
And with JSON Parse I have not been able to obtain them, since it only gives me 3 data. and it’s more data.
Hi there.
I need help, I need to extract a lot of data from a text that chatgpt gives me in JSON format.
And with JSON Parse I have not been able to obtain them, since it only gives me 3 data. and it’s more data.
Hey Delegate
Pretty sure it is cause your output data has the same keys e.g.
“MES”
“CODIGO 020”
“CODIGO 142”
“CODIGO 538”
Wild guess here, does your data end with August 2023?
/Riko
Hello GIGO, thank you for your response, do you know how I could do it so that it delivers all the output content to me, every month?
Hey Delegate
Wau this was a learning experience for me
I hope the solution solve your needs.
Solution - Regex - String with multiple matching keys.json (16.2 KB)
Solution
What the provided solution does is split up the text-sting into key : value pairs of groups of four (4), since they are repeating themself.
Then they are split-up again, mapping key : value pair to a collection keys and values.
So in short, what you go from having is…
A string like this, with multiple key’s named the same:
"MES": "Septiembre 2024","CÓDIGO 020": "No encontrado","CÓDIGO 124": "No encontrado","CÓDIGO 538": "No encontrado","MES": "Agosto 2024","CÓDIGO 020": "No encontrado","CÓDIGO 124": "No encontrado","CÓDIGO 538": "294426","MES": "Julio 2024","CÓDIGO 020": "No encontrado","CÓDIGO 124": "No encontrado","CÓDIGO 538": "294632"
To groups of 4 key : value pairs, like this:
"MES": "Septiembre 2024","CÓDIGO 020": "No encontrado","CÓDIGO 124": "No encontrado","CÓDIGO 538": "No encontrado",
"MES": "Agosto 2024","CÓDIGO 020": "No encontrado","CÓDIGO 124": "No encontrado","CÓDIGO 538": "294426",
And down to an array of collections of key:value pairs
[
{
"array": [
{
"key-value": {
"MES": "Septiembre 2024",
"CÓDIGO 020": "No encontrado",
"CÓDIGO 124": "No encontrado",
"CÓDIGO 538": "No encontrado"
}
},
{
"key-value": {
"MES": "Agosto 2024",
"CÓDIGO 020": "No encontrado",
"CÓDIGO 124": "No encontrado",
"CÓDIGO 538": "294426"
}
}
]
}
]
Hope this is useful. It sure did take some time for me, this one.
But a great opportunity to learn something.
A big thanks to @samliew for a solution provided in another post. It really really help me on my way.
Link: Text Parser bundles to JSON object - How To - Make Community
Regex used:
1st text parser:
(?:[^,]*,|[^,]*$){4}
2nd text parser:
(?<key>[^"]+)":\s*"(?<value>[^"]+)
Resources: