mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
feat(Extract from File Node): Add option to set encoding for CSV files (#9392)
This commit is contained in:
parent
b5c7c061b7
commit
f13dbc9cc3
|
@ -17,7 +17,9 @@ export const description: INodeProperties[] = fromFile.description
|
||||||
if (newProperty.name === 'options') {
|
if (newProperty.name === 'options') {
|
||||||
newProperty.options = (newProperty.options as INodeProperties[]).map((option) => {
|
newProperty.options = (newProperty.options as INodeProperties[]).map((option) => {
|
||||||
let newOption = option;
|
let newOption = option;
|
||||||
if (['delimiter', 'fromLine', 'maxRowCount', 'enableBOM'].includes(option.name)) {
|
if (
|
||||||
|
['delimiter', 'encoding', 'fromLine', 'maxRowCount', 'enableBOM'].includes(option.name)
|
||||||
|
) {
|
||||||
newOption = { ...option, displayOptions: { show: { '/operation': ['csv'] } } };
|
newOption = { ...option, displayOptions: { show: { '/operation': ['csv'] } } };
|
||||||
}
|
}
|
||||||
if (option.name === 'sheetName') {
|
if (option.name === 'sheetName') {
|
||||||
|
|
|
@ -177,6 +177,26 @@ export const fromFileOptions: INodeProperties = {
|
||||||
placeholder: 'e.g. ,',
|
placeholder: 'e.g. ,',
|
||||||
description: 'Set the field delimiter, usually a comma',
|
description: 'Set the field delimiter, usually a comma',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Encoding',
|
||||||
|
name: 'encoding',
|
||||||
|
type: 'options',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
'/fileFormat': ['csv'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{ name: 'ASCII', value: 'ascii' },
|
||||||
|
{ name: 'Latin1', value: 'latin1' },
|
||||||
|
{ name: 'UCS-2', value: 'ucs-2' },
|
||||||
|
{ name: 'UCS2', value: 'ucs2' },
|
||||||
|
{ name: 'UTF-8', value: 'utf-8' },
|
||||||
|
{ name: 'UTF16LE', value: 'utf16le' },
|
||||||
|
{ name: 'UTF8', value: 'utf8' },
|
||||||
|
],
|
||||||
|
default: 'utf-8',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Exclude Byte Order Mark (BOM)',
|
displayName: 'Exclude Byte Order Mark (BOM)',
|
||||||
name: 'enableBOM',
|
name: 'enableBOM',
|
||||||
|
|
|
@ -92,6 +92,7 @@ export async function execute(
|
||||||
const parser = createCSVParser({
|
const parser = createCSVParser({
|
||||||
delimiter: options.delimiter as string,
|
delimiter: options.delimiter as string,
|
||||||
fromLine: options.fromLine as number,
|
fromLine: options.fromLine as number,
|
||||||
|
encoding: options.encoding as BufferEncoding,
|
||||||
bom: options.enableBOM as boolean,
|
bom: options.enableBOM as boolean,
|
||||||
to: maxRowCount > -1 ? maxRowCount : undefined,
|
to: maxRowCount > -1 ? maxRowCount : undefined,
|
||||||
columns: options.headerRow !== false,
|
columns: options.headerRow !== false,
|
||||||
|
|
Loading…
Reference in a new issue