fix csv import
This commit is contained in:
parent
d9bb6aad2d
commit
2ba10662d3
|
@ -7,6 +7,7 @@ const VALIDATORS = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const PARSERS = {
|
const PARSERS = {
|
||||||
|
number: attribute => Number(attribute),
|
||||||
datetime: attribute => new Date(attribute).toISOString(),
|
datetime: attribute => new Date(attribute).toISOString(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +25,7 @@ function parse(path, parsers) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
result.fromFile(path).subscribe(row => {
|
result.subscribe((row, lineNumber) => {
|
||||||
// For each CSV row parse all the columns that need parsed
|
// For each CSV row parse all the columns that need parsed
|
||||||
for (let key in parsers) {
|
for (let key in parsers) {
|
||||||
if (!schema[key] || schema[key].success) {
|
if (!schema[key] || schema[key].success) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const fs = require("fs")
|
const fs = require("fs")
|
||||||
const sharp = require("sharp")
|
// const sharp = require("sharp")
|
||||||
const fsPromises = fs.promises
|
const fsPromises = fs.promises
|
||||||
|
|
||||||
const FORMATS = {
|
const FORMATS = {
|
||||||
|
@ -7,14 +7,14 @@ const FORMATS = {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function processImage(file) {
|
async function processImage(file) {
|
||||||
const imgMeta = await sharp(file.path)
|
// const imgMeta = await sharp(file.path)
|
||||||
.resize(300)
|
// .resize(300)
|
||||||
.toFile(file.outputPath)
|
// .toFile(file.outputPath)
|
||||||
|
|
||||||
return {
|
// return {
|
||||||
...file,
|
// ...file,
|
||||||
...imgMeta,
|
// ...imgMeta,
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
async function process(file) {
|
async function process(file) {
|
||||||
|
|
Loading…
Reference in New Issue