question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Loading multiple datasets on start up

See original GitHub issue

Hi there 😃

Currently following through the tutorial on vis academy. http://vis.academy/#/kepler.gl/2-load-data The tutorial is super clear and easy to follow through. However, I’m having trouble loading two sets of data in componentDidMount. This is what I have tried so far:

  componentDidMount() {
    // Use processCsvData helper to convert csv file into kepler.gl structure {fields, rows}
    const data = Processors.processCsvData(nycTrips);
    // Use processCsvData helper to convert csv file into kepler.gl structure {fields, rows}
    const data_ta = Processors.processCsvData(dummydata01);
    // Create dataset structure
    const dataset = {
      data,
      info: {
        // `info` property are optional, adding an `id` associate with this dataset makes it easier
        // to replace it later
        id: "my_data"
      }
    };
    // Creaing a second dataset
    const dataset_ta = {
      data_ta,
      info: {
        // `info` property are optional, adding an `id` associate with this dataset makes it easier
        // to replace it later
        id: "data_ta"
      }
    };
    // addDataToMap action to inject dataset into kepler.gl instance
    // I'm parsing them in as an array
    this.props.dispatch(addDataToMap({ datasets: [dataset,data_ta] }));
  }```

Is this the right approach or am I totally on the wrong path?

Thanks in advance for your help. 

@heshan0131 

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
heshan0131commented, Sep 29, 2021

I’m importing 2 datasets in a functional component, just dropping the code exampe if it helps.

import dataset_a from "data.json"
import dataset_b from "datab.json"

......
const dispatch = useDispatch();

  useEffect(() => {
    if (dataset_a) {
      dispatch(
        addDataToMap({
          datasets: [
            {
              info: {
                label: "dataset a",
                id: "data_a",
              },
              data: dataset_a,
            },
            {
              info: {
                label: "dataset b",
                id: "data_b",
              },
              data: dataset_b,
            },
          ],
          option: {
            centerMap: true,
            readOnly: false,
          },
        })
      );
    }
  }, [dispatch, dataset_a]);

the way you pass in datasets to addDataToMap is correct, looking at the above code, you should add dataset_a to your useEffect dependencies and check if (dataset_a, dataset_b)

1reaction
rozajaycommented, Jul 19, 2018

I think I have managed to achieve this through change componentDidMount() function here.

componentDidMount() {
    // Use processCsvData helper to convert csv file into kepler.gl structure {fields, rows}
    const data_ta = Processors.processCsvData(nycTrips);
    // Use processCsvData helper to convert csv file into kepler.gl structure {fields, rows}
    const data_m = Processors.processCsvData(dataset01);
    var data = data_ta;
    // Create dataset structure
    const dataset_t = {
      data,
      info: {
        // `info` property are optional, adding an `id` associate with this dataset makes it easier
        // to replace it later
        id: "my_data"
      }
    };
    data = data_m;
    // Create dataset structure
    const dataset_s = {
      data,
      info: {
        // `info` property are optional, adding an `id` associate with this dataset makes it easier
        // to replace it later
        id: "my_data_s"
      }
    };
    // addDataToMap action to inject dataset into kepler.gl instance
    // I'm parsing them in as an array
    this.props.dispatch(addDataToMap({ datasets: [dataset_s,dataset_t] }));

  }`
Read more comments on GitHub >

github_iconTop Results From Across the Web

Loading multiple datasets on start up · Issue #172 - GitHub
I'm importing 2 datasets in a functional component, just dropping the code exampe if it helps. import dataset_a from "data.json" import ...
Read more >
Load multiple dataset at the same time - Dataiku Community
Hi, I need to load multiple dataset from my local pc to a dss project. Is there a way to load al the...
Read more >
Best Practice for Loading Multiple Datasets on Same Webpage
OPTION 1. Query the entire database initially, load into however many elements are required, hide them all and only show the relevant element...
Read more >
Solved: Loading multiple datasets in a single project
Solved: I need to load multiple datasets in a single project. But the project allows to load only 1 time. My requirement is...
Read more >
Load a dataset - Hugging Face
Begin by creating a dataset repository and upload your data files. Now you can use the load_dataset() function to load the dataset. >>>...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found