One format in Data OUT (arrayed), Another format in Data IN in the following step (not arrayed, without JSON format)
I have a Jotform trigger that gives me data OUT with the table info that is arrayed (group 1, group 2, etc) - see screenshot "trigger_dataout_format."
Then, in a “Code by Zapier” step, I need to parse the table info to make sure the info is created into different lines and columns in an Airtable database, but the data IN for the new step is not arrayed anymore - see "screenshot array_datain_format." . The data now shows in one unique group, instead of group 1, group 2, etc and it doesn't show in the format that is JSON with symbols (b{string}, ...]).
When I try to add a step “Code by Zapier” to re-do the array, because the “data in” doesn’t come in JSON format with the symbols ( {string}, ...]), I get NO DATA OUT. See screenshot below. So it's very difficult for me to work with the info received (data out) when Zapier changes the format of the data IN in the following action in one single group not in JSON format.
How come ZAPIER changes the format ? How can I work it out without the JSON format to create different lines in a database ? Please help.
I tried using line items with format > utilities > text to line item, loop and code by Zapier yesterday, but it handles easy data with just one data per line, whereas for my needs, I have 7 data per group.
I’m now trying to use Code by Zapier with Python instead of JS,
but I’m running into an error too.
Traceback (most recent call last): File "<string>", line 10, in the_function File "/var/lang/lib/python3.11/json/__init__.py", line 346, in loads return _default_decoder.decode(s) File "/var/lang/lib/python3
@DPAxione
You may not need to use a Code step or Formatter steps.
Try using Looping - Create Loop from Line Items, which will handle the existing arrays.
Then from the output of the Looping step, map the variables to the desired Airtable fields.
Each Loop iteration would create a new Airtable record.
@Troy Tessalone
Yes, I also tried loop, but when I use it, it asks for a delimiter (I put },{) and it doesnt take into account to remove the symbols ] at the beginning and end.
p{"Nom du site":"test_loop_1","Etage":"sous-sol","Nom du capteur associé à ce site":"loop1","Cas d'usage du capteur":"Consommation énergétique au compteur (GAZ)","Adresse (rue)":"3 ave jean","Adresse (code postal)":"75020","Adresse (commune)":"Malakoff"},{"Nom du site":"test_loop_2","Etage":"RDC","Nom du capteur associé à ce site":"loop2","Cas d'usage du capteur":"Consommation énergétique au compteur (EAU)","Adresse (rue)":"3 ave jean","Adresse (code postal)":"75020","Adresse (commune)":"Malakoff"},{"Nom du site":"test_loop_3","Etage":"7","Nom du capteur associé à ce site":"loop3","Cas d'usage du capteur":"Taux de remplissage des PAV - Verre","Adresse (rue)":"3 ave jean","Adresse (code postal)":"75020","Adresse (commune)":"Malakoff"}]
@DPAxione
For us to have full context, post screenshots with how your steps are outlined and configured.
Hello,
I ended up asking for a Python developer to help me. She also had trouble due to data changing format between steps, but she managed to help me by using “code by Zapier” in the following way :
import jsontry: output = json.loads(inputData.get("capteurs"))except json.JSONDecodeError as e: print(e) records = inputData.get("capteurs").split('\n\n') output = p] for record in records: capteur = {} for line in record.split('\n'): key, value = line.split(': ', 1) capteurakey] = value output.append(capteur)print(output)