Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ibgreen committed Oct 17, 2024
1 parent 9205577 commit 8da8e0e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions modules/csv/src/csv-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';
import type {Schema, ArrayRowTable, ObjectRowTable, TableBatch} from '@loaders.gl/schema';

import {log} from '@loaders.gl/loader-utils';
import {
AsyncQueue,
deduceTableSchema,
Expand All @@ -15,9 +16,6 @@ import {
import Papa from './papaparse/papaparse';
import AsyncIteratorStreamer from './papaparse/async-iterator-streamer';

type ObjectField = {name: string; index: number; type: any};
type ObjectSchema = {[key: string]: ObjectField} | ObjectField[];

// __VERSION__ is injected by babel-plugin-version-inline
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
Expand Down Expand Up @@ -320,7 +318,7 @@ function generateHeader(columnPrefix: string, count: number = 0): string[] {
return headers;
}

function deduceCSVSchema(row, headerRow, logger: Logger): Schema {
function deduceCSVSchema(row, headerRow): Schema {
const fields: Schema['fields'] = [];
for (let i = 0; i < row.length; i++) {
const columnName = (headerRow && headerRow[i]) || i;
Expand All @@ -336,7 +334,7 @@ function deduceCSVSchema(row, headerRow, logger: Logger): Schema {
fields.push({name: String(columnName), type: 'utf8', nullable: true});
break;
default:
logger
log.warn(`CSV: Unknown column type: ${typeof value}`)();
fields.push({name: String(columnName), type: 'utf8', nullable: true});
}
}
Expand All @@ -350,6 +348,9 @@ function deduceCSVSchema(row, headerRow, logger: Logger): Schema {
}

// TODO - remove
// type ObjectField = {name: string; index: number; type: any};
// type ObjectSchema = {[key: string]: ObjectField} | ObjectField[];

// function deduceObjectSchema(row, headerRow): ObjectSchema {
// const schema: ObjectSchema = headerRow ? {} : [];
// for (let i = 0; i < row.length; i++) {
Expand Down

0 comments on commit 8da8e0e

Please sign in to comment.