Skip to content

Commit a1e6885

Browse files
authored
Merge pull request #57 from GooeyAI/fix-datatable-parsing
fix: filters out empty columns and add defval to sheet_to_json
2 parents 079972e + fe5abd0 commit a1e6885

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

app/dataTable.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,13 @@ export function DataTable({ fileUrl }: { fileUrl: string }) {
9090
const rows: Array<any> = XLSX.utils.sheet_to_json(sheet, {
9191
range: range,
9292
raw: false,
93+
defval: "",
9394
});
9495
if (!rows.length) return;
96+
const filteredColumns = Object.keys(rows[0]).filter(colName => !colName.startsWith("__EMPTY"));
9597
setColumns(
9698
Array.from(
97-
Object.keys(rows[0]).map((colName) => {
99+
filteredColumns.map((colName) => {
98100
const width = Math.min(
99101
Math.max(
100102
...rows.map((row) => `${row[colName] || ""}`.length * 8),

0 commit comments

Comments
 (0)