mirror of
https://github.com/iptv-org/database.git
synced 2024-11-09 22:16:38 -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 csv2json = require('csvtojson')
|
||||||
|
const chalk = require('chalk')
|
||||||
|
const logger = require('./logger')
|
||||||
const fs = require('mz/fs')
|
const fs = require('mz/fs')
|
||||||
const {
|
const {
|
||||||
Parser,
|
Parser,
|
||||||
|
@ -10,6 +12,7 @@ const csv2jsonOptions = {
|
||||||
checkColumn: true,
|
checkColumn: true,
|
||||||
trim: true,
|
trim: true,
|
||||||
delimiter: ',',
|
delimiter: ',',
|
||||||
|
eol: '\r\n',
|
||||||
colParser: {
|
colParser: {
|
||||||
countries: listParser,
|
countries: listParser,
|
||||||
languages: listParser,
|
languages: listParser,
|
||||||
|
@ -32,10 +35,14 @@ const json2csv = new Parser({
|
||||||
|
|
||||||
const csv = {}
|
const csv = {}
|
||||||
|
|
||||||
csv.load = async function (filepath) {
|
csv.fromFile = async function (filepath) {
|
||||||
return csv2json(csv2jsonOptions).fromFile(filepath)
|
return csv2json(csv2jsonOptions).fromFile(filepath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
csv.fromString = async function (filepath) {
|
||||||
|
return csv2json(csv2jsonOptions).fromString(filepath)
|
||||||
|
}
|
||||||
|
|
||||||
csv.save = async function (filepath, data) {
|
csv.save = async function (filepath, data) {
|
||||||
const string = json2csv.parse(data)
|
const string = json2csv.parse(data)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue