fixes spelling of delimiters

This commit is contained in:
mikesealey 2025-01-31 10:40:03 +00:00
parent 690f1a6ae6
commit aace287ded
1 changed files with 3 additions and 3 deletions

View File

@ -1,9 +1,9 @@
import csv from "csvtojson" import csv from "csvtojson"
export async function jsonFromCsvString(csvString: string) { export async function jsonFromCsvString(csvString: string) {
const possibleDelimeters = [",", ";", ":", "|", "~", "\t", " "] const possibleDelimiters = [",", ";", ":", "|", "~", "\t", " "]
for (let i = 0; i < possibleDelimeters.length; i++) { for (let i = 0; i < possibleDelimiters.length; i++) {
let headers: string[] | undefined = undefined let headers: string[] | undefined = undefined
let headerMismatch = false let headerMismatch = false
@ -14,7 +14,7 @@ export async function jsonFromCsvString(csvString: string) {
// with the keys but empty values // with the keys but empty values
const result = await csv({ const result = await csv({
ignoreEmpty: false, ignoreEmpty: false,
delimiter: possibleDelimeters[i], delimiter: possibleDelimiters[i],
}).fromString(csvString) }).fromString(csvString)
for (const [, r] of result.entries()) { for (const [, r] of result.entries()) {
// The purpose of this is to find rows that have been split // The purpose of this is to find rows that have been split