1
0
Fork 0
mirror of synced 2024-07-01 04:21:06 +12:00

fix csv import

This commit is contained in:
Martin McKeaveney 2020-10-14 13:09:03 +01:00
parent 72746c6e07
commit 2ae3191758
2 changed files with 10 additions and 9 deletions

View file

@ -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) {

View file

@ -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) {