From 2ba10662d38a9cec6f80a52eef75bbef207ee23f Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 14 Oct 2020 13:09:03 +0100 Subject: [PATCH] fix csv import --- packages/server/src/utilities/csvParser.js | 3 ++- packages/server/src/utilities/fileProcessor.js | 16 ++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/server/src/utilities/csvParser.js b/packages/server/src/utilities/csvParser.js index 872ee5f8a4..aacb599676 100644 --- a/packages/server/src/utilities/csvParser.js +++ b/packages/server/src/utilities/csvParser.js @@ -7,6 +7,7 @@ const VALIDATORS = { } const PARSERS = { + number: attribute => Number(attribute), 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 (let key in parsers) { if (!schema[key] || schema[key].success) { diff --git a/packages/server/src/utilities/fileProcessor.js b/packages/server/src/utilities/fileProcessor.js index 3e580e9e37..4c219b758f 100644 --- a/packages/server/src/utilities/fileProcessor.js +++ b/packages/server/src/utilities/fileProcessor.js @@ -1,5 +1,5 @@ const fs = require("fs") -const sharp = require("sharp") +// const sharp = require("sharp") const fsPromises = fs.promises const FORMATS = { @@ -7,14 +7,14 @@ const FORMATS = { } async function processImage(file) { - const imgMeta = await sharp(file.path) - .resize(300) - .toFile(file.outputPath) + // const imgMeta = await sharp(file.path) + // .resize(300) + // .toFile(file.outputPath) - return { - ...file, - ...imgMeta, - } + // return { + // ...file, + // ...imgMeta, + // } } async function process(file) {