From 66c18bf64d3101d47fda2bfb136dc14a47162975 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sun, 20 Feb 2022 07:05:50 +0300 Subject: [PATCH] Update csv.js --- scripts/core/csv.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/scripts/core/csv.js b/scripts/core/csv.js index b53b82eb..b2429b66 100644 --- a/scripts/core/csv.js +++ b/scripts/core/csv.js @@ -22,15 +22,17 @@ const csv2jsonOptions = { logo: nullable, subdivision: nullable, city: nullable, - network: nullable + network: nullable, + website: nullable } } const json2csv = new Parser({ - transforms: [flattenArray], + transforms: [flattenArray, formatBool], formatters: { string: stringQuoteOnlyIfNecessary() - } + }, + eol: '\r\n' }) const csv = {} @@ -66,6 +68,18 @@ function flattenArray(item) { return item } +function formatBool(item) { + for (let prop in item) { + if (item[prop] === false) { + item[prop] = 'FALSE' + } else if (item[prop] === true) { + item[prop] = 'TRUE' + } + } + + return item +} + function listParser(value) { return value.split(';').filter(i => i) }