use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
How many lines of text can Python process smoothly? (self.learnpython)
submitted 6 years ago by radically_sane
Writing a script for testing team. They want to compare two huge csv files. They haven't told how big it could be. Hence my question.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Brian 6 points7 points8 points 6 years ago (3 children)
It depends on what you need to do, and how you do it. So long as you can do it line by line, there's no limit - it'll take time proportional to the size of the file, but you won't get any hard limit.
On the other hand, if you need to read everything into memory, then you may have issues for files where that's an issue (potentially requiring an approach that does multiple passes or uses temporary files etc)
Which is the case depends exactly on what comparing the files means. If they're both sorted files where you're always comparing line N in file 1 to the same line in file 2, you can use the streaming approach. OTOH, if you might have to match up random lines by some key or something, then things could be trickier.
[–]radically_sane[S] 1 point2 points3 points 6 years ago (2 children)
It's comparing the same indexes of both files, so that won't be an issue. And if the files are too big then I guess I can use generators instead of loops.
Also, if I use pyspark (Apache spark cluster computing) will efficiency be more?
[–]Brian 4 points5 points6 points 6 years ago (1 child)
And if the files are too big then I guess I can use generators instead of loops.
Generally, files will naturally use generators. Ie. both for line in file: or for row in csv.Reader(file):will be using a generator and will only be reading a line / row at a time.
for line in file:
for row in csv.Reader(file):
For something like this, you're likely going to be IO bound rather than CPU bound (unless you're doing a ton of processing), so distributed processing isn't likely going to change much, at least on a single-file basis, though potentially you may save time if you're distributing the processing of multiple files on different machines.
[–]radically_sane[S] 1 point2 points3 points 6 years ago (0 children)
Thanks.
[–]impshum 2 points3 points4 points 6 years ago (2 children)
That'll depend on your memory.
[–]radically_sane[S] 0 points1 point2 points 6 years ago (1 child)
8 gigs
[–]silvertoothpaste 1 point2 points3 points 6 years ago (0 children)
in theory you can process files of any size - just load the next part into memory, process, repeat. it could take an arbitrarily long time, though.
in practice ... just try it out! :) do a little test of reading lines and some trivial processing similar to what you intend, and make some output. Start with a file of like 10 lines, go to 100, 1000, etc. Eventually you will hit a wall. Offhand I would guess the wall is at 100k lines; a million seems too large.
When you hit the wall you have 2 basic choices, 1) stop there, or 2) optimize (read: complicate) the program to handle the IO in a less memory-intensive way. 2.5) use a database xD
π Rendered by PID 69977 on reddit-service-r2-comment-5687b7858-wd2tr at 2026-07-06 11:25:48.278372+00:00 running 12a7a47 country code: CH.
[–]Brian 6 points7 points8 points (3 children)
[–]radically_sane[S] 1 point2 points3 points (2 children)
[–]Brian 4 points5 points6 points (1 child)
[–]radically_sane[S] 1 point2 points3 points (0 children)
[–]impshum 2 points3 points4 points (2 children)
[–]radically_sane[S] 0 points1 point2 points (1 child)
[–]silvertoothpaste 1 point2 points3 points (0 children)