From bf67ceff5269074c8d052a3b895b44883a07f0f8 Mon Sep 17 00:00:00 2001 From: James Scott-Brown Date: Mon, 26 Jul 2021 15:29:52 +0100 Subject: [PATCH] allow upload of CSV files with periods in filenames --- web/src/vistorian.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/web/src/vistorian.ts b/web/src/vistorian.ts index 6b50be2..a25eeb5 100644 --- a/web/src/vistorian.ts +++ b/web/src/vistorian.ts @@ -142,12 +142,16 @@ export function loadCSV(files: File[], callBack: Function, sessionid: string) { } var i: number = readers.indexOf((f.target)); fileContents[i] = obj; - var content: any = fileContents[i].content.replace(', "', ',"').replace('" ,', '",') - table = new VTable( - // eliminate spaces in the name because they will - // interfere with creating html element ids - // clean ', "' - files[i].name.replace('.csv', '').replace(/\s/g, '_').trim(), + var content: any = fileContents[i].content.replace(', "', ',"').replace('" ,', '",'); + + // spaces or periods would interfere with creating html element ids + var cleanName = files[i].name + .replace('.csv', '') + .replace(/[\s\.]/g, '_') + .trim(); + + var table = new VTable( + cleanName, Papa.parse(content, // { // // quotes: true,