Is there a way to read 10000 lines from a file in python?

Posted by windsound on Stack Overflow See other posts from Stack Overflow or by windsound
Published on 2012-06-18T21:05:02Z Indexed on 2012/06/18 21:16 UTC
Read the original article Hit count: 153

Filed under:

I am relatively new in python, was working on C a lot. Since I was seeing so many new functions in python that I do not know, I was wondering if there is a function that can request 10000 lines from a file in python.

Something like this is what I expect if that kind of function exist:

lines = get_10000_lines(file_pointer)

Did python have a build-in function or is there any module that I can download for this? If not, how do I do this to be easiest way. I need to analyze a huge file so I want to read 10000 lines and analyze per time to save memory.

Thanks for helping!

© Stack Overflow or respective owner

Related posts about python