R
R
reus2016-12-15 17:46:54
Django
reus, 2016-12-15 17:46:54

The maximum number of lines in a file for normal reading?

Tell me please. I have a file generated from database data.
Each line looks like this:

2431387 ce/ce41395ee6b9cd31a89db1fb60646c.JPG ce/thumbs/ce41395ee6b9cd31a89db1fb60646c.JPG old-2015-1/1/7\n

(Number path1 path2 path3)
The file weighs ~ 900 mb, it contains ~5.9 million lines
I read only with the help of readline()
Should it be divided into parts, and if so, into how many parts should it be divided? (The script transfers images, will run on the server (~10-15 GB of RAM is free, so there are only restrictions on hdd + cpu))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vlad, 2016-12-15
@d1skort

All you need is:

with open("log.txt") as infile:
    for line in infile:
        do_something_with(line)

We read one line at a time without loading the entire file into memory.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question