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) }