Skip to content

Commit

Permalink
Fix loading samples with CSV
Browse files Browse the repository at this point in the history
  • Loading branch information
lixun910 committed Dec 21, 2023
1 parent de8cb97 commit c3fe5a4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions examples/demo-app/src/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,16 @@ export const loadRemoteResourceSuccess = (state, action) => {
// TODO: replace generate with a different function
const datasetId = action.options.id || generateHashId(6);
const {dataUrl} = action.options;

let data = action.response;
let processorMethod = processRowObject;

// TODO: create helper to determine file ext eligibility
if (dataUrl.includes('.json') || dataUrl.includes('.geojson')) {
if (dataUrl.includes('.csv')) {
processorMethod = processRowObject;
// loaders.gl csv loader returns ArrayRowTable{data, shape: 'arrary-row-table'}
data = action.response.data;
} else if (dataUrl.includes('.json') || dataUrl.includes('.geojson')) {
processorMethod = processGeojson;
} else if (dataUrl.includes('.arrow')) {
processorMethod = processArrowTable;
Expand All @@ -102,7 +109,7 @@ export const loadRemoteResourceSuccess = (state, action) => {
info: {
id: datasetId
},
data: processorMethod(action.response)
data: processorMethod(data)
};

const config = action.config ? KeplerGlSchema.parseSavedConfig(action.config) : null;
Expand Down

0 comments on commit c3fe5a4

Please sign in to comment.