Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use python read for text dataset #715

Merged
merged 8 commits into from Oct 5, 2020
Merged

Conversation

lhoestq
Copy link
Member

@lhoestq lhoestq commented Oct 5, 2020

As mentioned in #622 the pandas reader used for text dataset doesn't work properly when there are \r characters in the text file.

Instead I switched to pure python using open and read.
From my benchmark on a 100MB text file, it's the same speed as the previous pandas reader.

Copy link
Member

@thomwolf thomwolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok :)

datasets/text/text.py Outdated Show resolved Hide resolved
@thomwolf
Copy link
Member

thomwolf commented Oct 5, 2020

One thing though, could we try to read the files in parallel?

@lhoestq
Copy link
Member Author

lhoestq commented Oct 5, 2020

We could but I'm not sure this would help a lot since the bottleneck is the drive IO if the files are big enough.
It could make sense for very small files.

@lhoestq
Copy link
Member Author

lhoestq commented Oct 5, 2020

Looks like windows is not a big fan of this approach
I'm working on a fix

@thomwolf
Copy link
Member

thomwolf commented Oct 5, 2020

I remember issue #546 where this was kinda requested (but maybe IO would bottleneck). What do you think?

@lhoestq
Copy link
Member Author

lhoestq commented Oct 5, 2020

I think it's worth testing multiprocessing. It could also be something we add to our speed benchmarks

@BramVanroy
Copy link
Contributor

I remember issue #546 where this was kinda requested (but maybe IO would bottleneck). What do you think?

It still would be interesting I think, especially in scenarios where IO is less of an issue (SSDs particularly) and where there are many smaller files. Wrapping this function in a pool.map is perhaps an easy thing to try.

@lhoestq
Copy link
Member Author

lhoestq commented Oct 5, 2020

Merging this one for now for the patch release

@lhoestq lhoestq merged commit 0ec694c into master Oct 5, 2020
@lhoestq lhoestq deleted the use-python-read-for-text-dataset branch October 5, 2020 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants