From bf3dcc1b045357dda3bc78a70e7fbdd929565b81 Mon Sep 17 00:00:00 2001 From: Nick Playfair <842413+nplayfair@users.noreply.github.com> Date: Tue, 10 Jun 2025 16:30:34 +0100 Subject: [PATCH] Reformat --- index.html | 15 --------------- src/csvToJSON.ts | 2 -- src/index.ts | 13 ++++++++++--- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/index.html b/index.html index 305603a..c157fc0 100644 --- a/index.html +++ b/index.html @@ -31,20 +31,5 @@ - diff --git a/src/csvToJSON.ts b/src/csvToJSON.ts index 59bcc8e..21bdabc 100644 --- a/src/csvToJSON.ts +++ b/src/csvToJSON.ts @@ -1,6 +1,4 @@ import { isJunk } from './utils'; - -const csvBOM = '/tests/bom.csv'; const csv = require('csvtojson'); export function csvToJSON(csvBOM: string): void { diff --git a/src/index.ts b/src/index.ts index 6ff8ebd..8fb927a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,18 +1,25 @@ -// Modules +//Modules import { csvToJSON } from './csvToJSON'; +//DOM elements const input = document.getElementById('csvInput') as HTMLInputElement; -const csvText = document.getElementById('csvText') as HTMLPreElement; +const csvTextOutput = document.getElementById('csvText') as HTMLPreElement; +let rawCSV: string; //Functions function handleUpload(event: Event) { const file = (event.target as HTMLInputElement).files![0]; if (file) { + //Read in from the file const reader = new FileReader(); reader.onload = function (e) { const content = (e.target as FileReader).result; if (content === null) throw new Error('CSV Cannot be null.'); - csvText.innerText = content.toString(); + const csvString = content.toString(); + //Display the CSV contents + csvTextOutput.innerText = csvString; + //Get JSON object from the file + console.log(); }; reader.readAsText(file); }