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.

Reading in multiple files in one go.

See original GitHub issue

Is your feature request related to a problem? Please describe.

I have a folder with lots and lots of json files. Can I read them in all at once?

Describe the solution you’d like

It’d be nice if all of our readers allowed for a '*' or a Path.glob that allows you to read in lots of files at once.

Something like:

Clumper.read_json("folder/*.json") 
Clumper.read_json(pathlib.Path("folder").glob("*"))

Additional context

As far as an implementation goes, we can probably solve this nicely with a decorator. Assuming the function that it wraps is a file-reader we should not need to touch the internal readers.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:20 (20 by maintainers)

github_iconTop GitHub Comments

1reaction
samarpan-raicommented, Sep 14, 2020

@koaning Gefeliciteerd!

I agree with @samukweku. It makes things more complicated. I would suggest we support the following inputs for reading jsonl

# Using string
Clumper.read_jsonl("folder/*.jsonl")
Clumper.read_jsonl("folder/*.jsonl", n=50) # 50 lines per found file

# Using Path.glob
Clumper.read_jsonl(pathlib.Path("folder").glob("*.jsonl"))
Clumper.read_jsonl(pathlib.Path("folder").glob("*.jsonl"), n=50) # 50 lines per found file

I am having some trouble with accessing the path argument in the decorator, maybe we can discuss how to solve it? We could discuss it in this issue but it would be unnecessarily bloated with messages so I suggest we talk in some chat platform. Is there any platform you prefer to talk in? I can create a room in gitter for these discussions as it has easy integration with github.

1reaction
samukwekucommented, Aug 31, 2020

I dont think we should. separating single and multiple files seems to be an easier and more maintainable approach

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to import multiple .csv files at once? - Stack Overflow
Just write and swap in a little function that not only reads the files but immediately appends a filename to each record read....
Read more >
How to Read Multiple CSV Files in R - Spark by {Examples}
Read Multiple CSV Files in R (The best approach)​​ In order to read multiple CSV files or all files from a folder in...
Read more >
How can I read in multiple files? | R Code Fragments
You may at times wish to read a set of data files into R. The code below demonstrates how to do so looping...
Read more >
How to read multiple text files from folder in Python?
In this article, we will learn how to read multiple text files from a folder using python. Approach: Import modules; Add path of...
Read more >
How to Read Multiple Excel or CSV Files Together
In R, you can write a script to read all the files in the same folder and bring them relatively easily. Let's say...
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