mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
fix(Spreadsheet File Node): Fix include empty cells not working with v2 (#7505)
Github issue / Community forum post (link here to close automatically): Ticket#763644
This commit is contained in:
parent
8ff9f97493
commit
05e6f2a6ac
|
@ -166,6 +166,18 @@ describe('Execute Spreadsheet File Node', () => {
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
description: 'execute includeempty.json',
|
||||
input: {
|
||||
workflowData: loadWorkflow('workflow.empty.json', 'includeempty.csv'),
|
||||
},
|
||||
output: {
|
||||
nodeData: {
|
||||
'Include Empty': [[{ json: { A: '1', B: '', C: '3' } }]],
|
||||
'Ignore Empty': [[{ json: { A: '1', C: '3' } }]],
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const nodeTypes = Helpers.setup(tests);
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
A,B,C
|
||||
1,,3
|
|
|
@ -0,0 +1,90 @@
|
|||
{
|
||||
"meta": {},
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"fileFormat": "csv",
|
||||
"options": {
|
||||
"includeEmptyCells": false
|
||||
}
|
||||
},
|
||||
"id": "8aed098d-3c0b-43c9-b7e8-c4106c88b409",
|
||||
"name": "Ignore Empty",
|
||||
"type": "n8n-nodes-base.spreadsheetFile",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1160,
|
||||
500
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "649db2c5-27dc-4cec-b084-8982632311e7",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
720,
|
||||
360
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"fileSelector": "includeempty.csv"
|
||||
},
|
||||
"id": "5056b8c4-fb6e-4ca1-9bc1-33f5db4027ad",
|
||||
"name": "Read Binary File",
|
||||
"type": "n8n-nodes-base.readBinaryFiles",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
940,
|
||||
360
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"fileFormat": "csv",
|
||||
"options": {
|
||||
"includeEmptyCells": true
|
||||
}
|
||||
},
|
||||
"id": "a4822e75-d638-45c8-887f-0487d5237267",
|
||||
"name": "Include Empty",
|
||||
"type": "n8n-nodes-base.spreadsheetFile",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1160,
|
||||
280
|
||||
]
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Read Binary File",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Read Binary File": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Include Empty",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Ignore Empty",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -92,6 +92,11 @@ export class SpreadsheetFileV2 implements INodeType {
|
|||
to: maxRowCount > -1 ? maxRowCount : undefined,
|
||||
columns: options.headerRow !== false,
|
||||
onRecord: (record) => {
|
||||
if (!options.includeEmptyCells) {
|
||||
record = Object.fromEntries(
|
||||
Object.entries(record).filter(([_key, value]) => value !== ''),
|
||||
);
|
||||
}
|
||||
rows.push(record);
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue