KEEP LEARNING
Build the bigger picture.
The Workflow Engineer connects individual n8n concepts to testing, deployment and running a complete workflow.
Tips > Building Workflows
n8n has built-in CSV and XML support, but it fails on malformed data, non-standard delimiters, or XML with namespaces.
Parse CSV or XML inside a Code node when n8n's built-in parsing fails on malformed data, non-standard delimiters, or namespaced XML. A Code node gives you full control: you can skip extra header lines, set a custom delimiter, respect quoted fields that contain the delimiter, and coerce types, returning one clean JSON item per row.
n8n has built-in CSV and XML support, but it fails on malformed data, non-standard delimiters, or XML with namespaces. A Code node lets you handle edge cases with full control over parsing logic.
Real-world example: A vendor sends daily inventory updates as a CSV attachment where some fields contain commas inside quotes, the delimiter is a semicolon, and there is a two-line header that the Spreadsheet File node chokes on.
// Mode: Run Once for All Items
const csvString = $input.first().json.csvData;
// Skip the first two header lines, use semicolon delimiter
const lines = csvString.split('\n').slice(2).filter(l => l.trim());
function parseCSVLine(line, delimiter = ';') {
const result = [];
let current = '';
let inQuotes = false;
for (const char of line) {
if (char === '"') {
inQuotes = !inQuotes;
} else if (char === delimiter && !inQuotes) {
result.push(current.trim());
current = '';
} else {
current += char;
}
}
result.push(current.trim());
return result;
}
const headers = ['sku', 'name', 'quantity', 'warehouse', 'lastUpdated'];
return lines.map(line => {
const values = parseCSVLine(line);
const obj = {};
headers.forEach((h, i) => { obj[h] = values[i] ?? ''; });
obj.quantity = parseInt(obj.quantity, 10) || 0;
return { json: obj };
});Warning: Large Files. For CSV files larger than 10 MB, consider processing them in chunks using the Split In Batches node upstream, or switch to filesystem binary mode (see the Performance tips).
Related: Use Edit Fields in "Map Each" Mode for Simple Renames · Configure Payload Size and Binary Data Mode for Large Files
KEEP LEARNING
The Workflow Engineer connects individual n8n concepts to testing, deployment and running a complete workflow.
APPLY IT TO YOUR SYSTEM
Bring the process, the tools involved and an example of where the current workflow gets stuck.