Double quotes in json code

Hello, I need to remove this double quote at the beginning and end of the json code, because it is coming out in the csv file, could someone help me?

Hi @LorenzoSbeghen :wave:

It would be helpful if you could share your full workflow or some example JSON data here, but would adding .stringify or even .replace(/\"/g, "") where you’re returning that value help you in this case? Just as a heads up, that regex will remove all quotes, so it may not be a proper solution depending on the data you’re passing.

Sorry I’m new here, to share the workflow do I need to pay for an n8n plan?

Hi @LorenzoSbeghen - Not at all! You can find instructions here: Export and import | n8n Docs

If you can copy and paste the nodes and then place the JSON between two sets of three backticks ( ``` ) that would be ideal :smiley:

1 Like

So the quotes here are essentially just to show you’re passing along a string - can you try passing the data directly into the CSV node without the code nodes? :thinking: If that doesn’t work, can you provide some example json data from the trigger and the sheets node? Obviously redact or change anything that would be sensitive! But maybe we could figure it out from there :slight_smile:

The data is going through the code node to change the csv file delimiter comma to semicolon, below is json from google sheets.

[
{
“row_number”: 1333,
“ITEM”: “XPL4407.005.001”,
“CODIGO_LINHA”: 1005,
“NRO_PEDIDO”: 130211,
“DT_EMISSAO”: “6/23/2023”
},
{
“row_number”: 1334,
“ITEM”: “TP11PRC”,
“CODIGO_LINHA”: 17,
“NRO_PEDIDO”: 130211,
“DT_EMISSAO”: “6/23/2023”
},
{
“row_number”: 1335,
“ITEM”: “GAM4316.0006”,
“CODIGO_LINHA”: 11,
“NRO_PEDIDO”: 130211,
“DT_EMISSAO”: “6/23/2023”
},
{
“row_number”: 1336,
“ITEM”: “ORD1422.0048”,
“CODIGO_LINHA”: 56,
“NRO_PEDIDO”: 130211,
“DT_EMISSAO”: “6/23/2023”
},
{
“row_number”: 1337,
“ITEM”: “ARB8274.0563”,
“CODIGO_LINHA”: 12,
“NRO_PEDIDO”: 130211,
“DT_EMISSAO”: “6/23/2023”
},
{
“row_number”: 1338,
“ITEM”: “XPL1424.008.001”,
“CODIGO_LINHA”: 1005,
“NRO_PEDIDO”: 130211,
“DT_EMISSAO”: “6/23/2023”
},
{
“row_number”: 1348,
“ITEM”: “XOR1212.057.001”,
“CODIGO_LINHA”: 1056,
“NRO_PEDIDO”: 130218,
“DT_EMISSAO”: “6/23/2023”
},
{
“row_number”: 1349,
“ITEM”: “ORD3637.0139”,
“CODIGO_LINHA”: 56,
“NRO_PEDIDO”: 130218,
“DT_EMISSAO”: “6/23/2023”
},
{
“row_number”: 1350,
“ITEM”: “ORD3637.0047”,
“CODIGO_LINHA”: 56,
“NRO_PEDIDO”: 130218,
“DT_EMISSAO”: “6/23/2023”
},
{
“row_number”: 1351,
“ITEM”: “ORD3637.0123”,
“CODIGO_LINHA”: 56,
“NRO_PEDIDO”: 130218,
“DT_EMISSAO”: “6/23/2023”
},
{
“row_number”: 1352,
“ITEM”: “PLU1444.0011”,
“CODIGO_LINHA”: 5,
“NRO_PEDIDO”: 130218,
“DT_EMISSAO”: “6/23/2023”
},
{
“row_number”: 1353,
“ITEM”: “XAR8816.219.001”,
“CODIGO_LINHA”: 1012,
“NRO_PEDIDO”: 130218,
“DT_EMISSAO”: “6/23/2023”
}
]

Here is how the csv file is outputting

image

Had to recruit the help of @Jon here for a sanity check :sweat_smile:

Looks like this is actually to be expected - Our node will write the JSON table to the CSV file, but in this case the table is just one row with all of your data in it.

If you were to attach the Spreadsheet node directly after the Sheets node, it would create the CSV file properly – but our node currently only handles comma separation. So if you wanted a ; option the best option would be to write it to a file using the execute command node to add it to a file locally, then a read file node to pick it up again.

You may also want to add your voice to this feature request here and upvote it: CSV spreadsheets with delimiter ;

2 Likes

I can’t promise anything but I will take a quick look this afternoon and see what would be involved with adding that.

2 Likes

Thanks, all the automations I’m doing require “;”, it will save my time. :grinning:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.