Is there a node that can convert csv file to individual fields?

Hi Community,

Describe the problem/error/question

I get the following format of data (chunk of data) in one field, is there a node that can read it and separate the data into individual fields so I can then insert into google sheets?

Here’s what I get in the field:
Invoice Number: 202502/3208824\nInvoice Date: 03 Feb 2025\nDue Date: 18 Feb 2025\nVendor Name: 1st Energy\nAccount Name: John Wicks\nCustomer ID: 408888\nAddress: \n4 Jetson Cres,\nMalvern BIC 3035\nSubtotal: $65.8686\nOriginal File Name: \nBillinBilling Pg Periodiod 2 January 2025 - 1 February 2025 BillinBilling Dag Dayyss 31\nUtility type: Electricity\nPeak Usage: 133.6750 kWh\nPeak Unit Price: $0.3036\nPeak Usage Cost: $40.58\nOff Peak Usage: 279.3250 kWh\nOff Peak Unit Price: -$0.0330\nOff Peak Usage Cost: $9.22 CR

By searching online, I read someone mentioned Spreadsheet node but I cannot find any node with the name spreadsheet. What I am after is something similar to excel or google sheet’s data import tool where user can sepcify the separator and it will then segregate each field individually based on the delimiter.

Information on your n8n setup

  • n8n version: 1.95.3
  • Running n8n via (Docker Self hosted):
  • **Operating system: Ubuntu

Thanks all!

1- Input node (Webhook, HTTP Request, or Function with sample data)
{
“data”: “Invoice Number: 202502/3208824\nInvoice Date: 03 Feb 2025\nDue Date: 18 Feb 2025\nVendor Name: 1st Energy\nAccount Name: John Wicks\nCustomer ID: 408888\nAddress: 1 Jetson Cres\nSubtotal: $65.8686\nPeak Usage: 133.6750 kWh\nPeak Unit Price: $0.3036\nPeak Usage Cost: $40.58”
}
You can use a Function node to simulate this field or receive it via Webhook.

2- Code node to transform the text to JSON

const input = $json.data;
const lines = input.split("\n"); // If the breaks are literal "\n"
const result = {};

lines.forEach(line => {
const parts = line.split(":");
if (parts.length >= 2) {
const key = parts[0].trim();
const value = parts.slice(1).join(":").trim(); // Combine values ​​with ":" inside
result[key] = value;
}
});

return [{ json: result }];

If the line breaks are real (not text “\n”, but actual breaks), replace split(“\n”) with split(“\n”).

3- Google Sheets Node → Append Row, select your document and spreadsheet.

In “Columns to add”, directly map the fields generated from the previous node: Invoice Number, Invoice Date, Vendor Name, etc.

You can use the Extract from file node for this:

Here is the content of the sample CSV which I load from disk in the sample:

id,name,email,age,city,salary,department,hire_date,active
1,John Smith,[email protected],28,New York,75000,Engineering,2022-03-15,true
2,Sarah Johnson,[email protected],34,Los Angeles,82000,Marketing,2021-07-22,true
3,Michael Brown,[email protected],29,Chicago,68000,Sales,2023-01-10,true
4,Emily Davis,[email protected],31,Houston,71000,HR,2022-09-05,false
5,David Wilson,[email protected],26,Phoenix,63000,Engineering,2023-04-18,true
6,Lisa Anderson,[email protected],37,Philadelphia,89000,Finance,2020-11-30,true
7,Robert Taylor,[email protected],42,San Antonio,95000,Management,2019-06-12,true
8,Jennifer Martinez,[email protected],25,San Diego,58000,Marketing,2023-08-07,true
9,William Garcia,[email protected],33,Dallas,77000,Engineering,2021-12-03,true
10,Amanda Rodriguez,[email protected],30,San Jose,84000,Sales,2022-05-20,false
11,Christopher Lee,[email protected],35,Austin,72000,IT,2021-02-14,true
12,Jessica White,[email protected],27,Jacksonville,66000,HR,2023-03-25,true
13,Matthew Harris,[email protected],39,Fort Worth,91000,Finance,2020-08-17,true
14,Ashley Clark,[email protected],32,Columbus,69000,Marketing,2022-10-11,true
15,Daniel Lewis,[email protected],24,Charlotte,55000,Engineering,2023-06-30,true 

Heres the result:

1 Like

Thanks both! that worked.
Originally thought that’s node specifically to do that but all good, function node works.

1 Like

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