From b3497d3846bce5cd9045d67acd0a072758deae24 Mon Sep 17 00:00:00 2001 From: kevmodrome Date: Fri, 18 Dec 2020 11:10:36 +0100 Subject: [PATCH 1/4] fixes encoding issue of file to work with non-english chars --- .../components/backend/TableNavigator/TableDataImport.svelte | 4 +++- packages/server/src/utilities/tests/test.csv | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/components/backend/TableNavigator/TableDataImport.svelte b/packages/builder/src/components/backend/TableNavigator/TableDataImport.svelte index d328df4b40..f7b612b296 100644 --- a/packages/builder/src/components/backend/TableNavigator/TableDataImport.svelte +++ b/packages/builder/src/components/backend/TableNavigator/TableDataImport.svelte @@ -18,6 +18,7 @@ let schema = {} let fields = [] + $: console.log(files[0]) $: valid = !schema || fields.every(column => schema[column].success) $: dataImport = { valid, @@ -43,6 +44,7 @@ } async function validateCSV() { + console.log(csvString) const response = await api.post("/api/tables/csv/validate", { csvString, schema: schema || {}, @@ -82,7 +84,7 @@ files = fileArray validateCSV() }) - reader.readAsBinaryString(fileArray[0]) + reader.readAsText(fileArray[0]) } async function omitColumn(columnName) { diff --git a/packages/server/src/utilities/tests/test.csv b/packages/server/src/utilities/tests/test.csv index 2266b348cd..2a193e4df2 100644 --- a/packages/server/src/utilities/tests/test.csv +++ b/packages/server/src/utilities/tests/test.csv @@ -1,4 +1,4 @@ "Name","Age","Address" -"Bert","4324","5 Sesame Street" +"Bertå","4324","5 Sesame Street" "Ernie","34","1 World Trade Center" "Big Bird","23423","44 Second Avenue" \ No newline at end of file From 55e364071f531e0c9faceec5de07cdbd1f554c9b Mon Sep 17 00:00:00 2001 From: kevmodrome Date: Fri, 18 Dec 2020 11:12:00 +0100 Subject: [PATCH 2/4] remove console logs --- .../components/backend/TableNavigator/TableDataImport.svelte | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/builder/src/components/backend/TableNavigator/TableDataImport.svelte b/packages/builder/src/components/backend/TableNavigator/TableDataImport.svelte index f7b612b296..810d7960f5 100644 --- a/packages/builder/src/components/backend/TableNavigator/TableDataImport.svelte +++ b/packages/builder/src/components/backend/TableNavigator/TableDataImport.svelte @@ -18,7 +18,6 @@ let schema = {} let fields = [] - $: console.log(files[0]) $: valid = !schema || fields.every(column => schema[column].success) $: dataImport = { valid, @@ -44,7 +43,6 @@ } async function validateCSV() { - console.log(csvString) const response = await api.post("/api/tables/csv/validate", { csvString, schema: schema || {}, From 67d98119b546e0d6847a741586d7ab6081b5ae12 Mon Sep 17 00:00:00 2001 From: kevmodrome Date: Fri, 18 Dec 2020 11:20:25 +0100 Subject: [PATCH 3/4] updates test --- packages/server/src/utilities/tests/csvParser.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/utilities/tests/csvParser.spec.js b/packages/server/src/utilities/tests/csvParser.spec.js index 5fc4a9ffe3..48e275fdd1 100644 --- a/packages/server/src/utilities/tests/csvParser.spec.js +++ b/packages/server/src/utilities/tests/csvParser.spec.js @@ -89,7 +89,7 @@ describe("CSV Parser", () => { }) ).toEqual([ { - Name: "Bert", + Name: "Bertå", }, { Name: "Ernie", From b6974cba0878f4e23180362872dbd68950a908e2 Mon Sep 17 00:00:00 2001 From: kevmodrome Date: Fri, 18 Dec 2020 11:29:26 +0100 Subject: [PATCH 4/4] update test snapshot --- .../src/utilities/tests/__snapshots__/csvParser.spec.js.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/utilities/tests/__snapshots__/csvParser.spec.js.snap b/packages/server/src/utilities/tests/__snapshots__/csvParser.spec.js.snap index 1966637f56..3c532413fa 100644 --- a/packages/server/src/utilities/tests/__snapshots__/csvParser.spec.js.snap +++ b/packages/server/src/utilities/tests/__snapshots__/csvParser.spec.js.snap @@ -5,7 +5,7 @@ Array [ Object { "Address": "5 Sesame Street", "Age": 4324, - "Name": "Bert", + "Name": "Bertå", }, Object { "Address": "1 World Trade Center",