Skip to Content
0 likes
Reading a Large Text File in Python Line by Line Level: Intermediate

for line in file reads one line at a time, so a 10 GB file uses almost no memory. read() and readlines() load everything. Count, filter and stop early without building a list, and read in blocks when there are no lines.

0 likes
Paginate Without OFFSET Level: Intermediate

Page through a table with keyset pagination: filter on the last row you showed and add a tie-breaker. After this, a later page costs the same as the first and rows do not repeat or vanish between pages.