Fix CSV import for files with no rows, just headers (#4160)

This commit is contained in:
Joshen Lim authored and GitHub committed 2021-11-30 13:51:03 +08:00
1 parent 434a16b92c
commit b72e80afb4
2 files changed
+5 -1

No files matched your search

@@ -62,6 +62,10 @@ export const inferColumnType = (column: string, rows: object[]) => {
// General strategy is to check the first row first, before checking across all the rows
// to ensure uniformity in data type. Thinking we do this as an optimization instead of
// checking all the rows up front.
// If there are no rows to infer for, default to text
if (rows.length === 0) return 'text'
const columnData = (rows[0] as any)[column]
const columnDataAcrossRows = rows.map((row: object) => (row as any)[column])
+1 -1
View File
@@ -393,7 +393,7 @@ export default class MetaStore implements IMetaStore {
// If the user is importing data via a spreadsheet
if (!isUndefined(importContent)) {
if (importContent.file) {
if (importContent.file && importContent.rowCount > 0) {
// Via a CSV file
const { error }: any = await this.insertRowsViaSpreadsheet(
importContent.file,