mirror of
https://github.com/iptv-org/database.git
synced 2024-11-21 18:42:31 -05:00
Update csv.js
This commit is contained in:
parent
a109031125
commit
af21b368bd
1 changed files with 8 additions and 1 deletions
|
@ -1,4 +1,6 @@
|
|||
const csv2json = require('csvtojson')
|
||||
const chalk = require('chalk')
|
||||
const logger = require('./logger')
|
||||
const fs = require('mz/fs')
|
||||
const {
|
||||
Parser,
|
||||
|
@ -10,6 +12,7 @@ const csv2jsonOptions = {
|
|||
checkColumn: true,
|
||||
trim: true,
|
||||
delimiter: ',',
|
||||
eol: '\r\n',
|
||||
colParser: {
|
||||
countries: listParser,
|
||||
languages: listParser,
|
||||
|
@ -32,10 +35,14 @@ const json2csv = new Parser({
|
|||
|
||||
const csv = {}
|
||||
|
||||
csv.load = async function (filepath) {
|
||||
csv.fromFile = async function (filepath) {
|
||||
return csv2json(csv2jsonOptions).fromFile(filepath)
|
||||
}
|
||||
|
||||
csv.fromString = async function (filepath) {
|
||||
return csv2json(csv2jsonOptions).fromString(filepath)
|
||||
}
|
||||
|
||||
csv.save = async function (filepath, data) {
|
||||
const string = json2csv.parse(data)
|
||||
|
||||
|
|
Loading…
Reference in a new issue