Giter Club home page Giter Club logo

Comments (4)

jrbourbeau avatar jrbourbeau commented on June 23, 2024

Thanks for the issue @simplew2011. We already support loading datasets from hugging face via fsspec's hf:// support (see https://docs.dask.org/en/stable/how-to/connect-to-remote-data.html). For example:

import dask.dataframe as dd
df = dd.read_parquet("hf://datasets/wikimedia/wikipedia/20231101.en")

Can you say more about what you're looking for? It could be things already work

from dask.

simplew2011 avatar simplew2011 commented on June 23, 2024
  • Currently, only JSONL files are support? loading JSON files is fail

    • json
    [
    {"id": 0, "text": "https://docs.dask.org/en/latest/bag-api.html"},
    {"id": 1, "text": "https://docs.dask.org/en/latest/bag-api.html"}
    ]
    
    • jsonl
    {"id": 0, "text": "https://docs.dask.org/en/latest/bag-api.html"}
    {"id": 1, "text": "https://docs.dask.org/en/latest/bag-api.html"}
    
    import dask.bag as db
    b_bg = db.read_text('examples/demos/datasets.jsonl').map(json.loads) # ok
    b_bg1 = db.read_text('examples/demos/datasets.json').map(json.load) # fail
    
  • I have a usage scenario where I have already used the datasets library to load raw data (such as local JSON and JSONL files). I would like to convert it directly to dask.dataframe in memory instead of converting it to parquet first

from dask.

jrbourbeau avatar jrbourbeau commented on June 23, 2024

Currently, only JSONL files are support? loading JSON files is fail

See this related Stackoverflow question and answer https://stackoverflow.com/questions/44889526/dask-bag-jsondecodeerror-when-reading-multiline-json-arrays. In short, the read_text function interprets every line of your file as a separate element.

I would like to convert it directly to dask.dataframe in memory instead of converting it to parquet first

Maybe you'll be better off just using Dask DataFrame's JSON reader? With data files like this:

data/0.json:

[
{"id": 0, "text": "https://docs.dask.org/en/latest/bag-api.html"},
{"id": 1, "text": "https://docs.dask.org/en/latest/bag-api.html"}
]

data/1.json:

[
{"id": 2, "text": "https://docs.dask.org/en/latest/bag-api.html"},
{"id": 3, "text": "https://docs.dask.org/en/latest/bag-api.html"}
]

You can read the data like this:

import dask.dataframe as dd

files = ["data/0.json", "data/1.json"]
df = dd.read_json("data/*.json", lines=False)
print(f"{df.compute() = }")

from dask.

simplew2011 avatar simplew2011 commented on June 23, 2024

thanks

from dask.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.