Skip to content

Commit

Permalink
fix: turn off type casting when use csv
Browse files Browse the repository at this point in the history
  • Loading branch information
nogorka committed May 14, 2024
1 parent 977c009 commit f6ec32e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/utils/process-file-formats.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import Papa from 'papaparse'
import store from '@/store'

function transformValue(value, columnName) {
if (value === '') return ''

const numberValue = Number(value)
if (!isNaN(numberValue)) return numberValue

return value
}

export const processCsv = (content) => {
try {
const lines = Papa.parse(content, {
header: true,
dynamicTyping: true,
skipEmptyLines: true
dynamicTyping: false,
skipEmptyLines: true,
transform: transformValue
})
const jsonData = lines.data
store.dispatch('updateInputPoints', jsonData)
Expand Down

0 comments on commit f6ec32e

Please sign in to comment.