mirror of
https://github.com/iptv-org/database.git
synced 2024-12-22 16:00:24 -05:00
Update csv.js
This commit is contained in:
parent
3d1e8cadc3
commit
66c18bf64d
1 changed files with 17 additions and 3 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue