Add csvutils
This commit is contained in:
parent
608a38489f
commit
29df12c247
|
@ -10,7 +10,7 @@ import { getDatasourceParams } from "../../../db/utils"
|
|||
import { context, events } from "@budibase/backend-core"
|
||||
import { Table, UserCtx } from "@budibase/types"
|
||||
import sdk from "../../../sdk"
|
||||
import csv from "csvtojson"
|
||||
import { jsonFromCsvString } from "../../../utilities/csv"
|
||||
|
||||
function pickApi({ tableId, table }: { tableId?: string; table?: Table }) {
|
||||
if (table && !tableId) {
|
||||
|
@ -104,7 +104,7 @@ export async function bulkImport(ctx: UserCtx) {
|
|||
export async function csvToJson(ctx: UserCtx) {
|
||||
const { csvString } = ctx.request.body
|
||||
|
||||
const result = await csv().fromString(csvString)
|
||||
const result = await jsonFromCsvString(csvString)
|
||||
|
||||
ctx.status = 200
|
||||
ctx.body = result
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
import csv from "csvtojson"
|
||||
|
||||
export async function jsonFromCsvString(csvString: string) {
|
||||
const result = await csv().fromString(csvString)
|
||||
return result
|
||||
}
|
Loading…
Reference in New Issue