Le vendredi 15 juin 2018 12:36:40 UTC+2, Steven D'Aprano a écrit :
> On Fri, 15 Jun 2018 01:01:03 -0700, francois.rabanel wrote:
>
> > I work with a file which contains millions lines, a simply file.read()
> > and I'm running out of memory
>
> Assuming each line is on average a hundred characters
On Fri, 15 Jun 2018 01:01:03 -0700, francois.rabanel wrote:
> I work with a file which contains millions lines, a simply file.read()
> and I'm running out of memory
Assuming each line is on average a hundred characters long, a million
lines is (approximately) 100 MB. Even on a computer with only
Le vendredi 15 juin 2018 02:42:12 UTC+2, Cameron Simpson a écrit :
> On 15Jun2018 00:24, Steven D'Aprano
> wrote:
> >On Fri, 15 Jun 2018 10:00:59 +1000, Cameron Simpson wrote:
> >> Francois, unless your regex can cross multiple lines it is better to
> >> search files like this:
> >>
> >> with o
On 15Jun2018 00:24, Steven D'Aprano
wrote:
On Fri, 15 Jun 2018 10:00:59 +1000, Cameron Simpson wrote:
Francois, unless your regex can cross multiple lines it is better to
search files like this:
with open(the_filename) as f:
for line in f:
... search the line for the regexp ...
T
On Fri, 15 Jun 2018 10:00:59 +1000, Cameron Simpson wrote:
> Francois, unless your regex can cross multiple lines it is better to
> search files like this:
>
> with open(the_filename) as f:
> for line in f:
> ... search the line for the regexp ...
>
> That way you only need to keep o
On 14Jun2018 16:54, Steven D'Aprano
wrote:
On Thu, 14 Jun 2018 09:26:44 -0700, francois.rabanel wrote:
My problem is, if I work on a huge file, I'll try to avoid to read the
file because it will be crash my computer :)
How does reading a file crash your computer?
Likely because he tried to
On Thu, 14 Jun 2018 09:26:44 -0700, francois.rabanel wrote:
> Hi,
>
> Here is my script :
>
> It propose to replace some words in a file with a regular expression. It
> create a copy to write on it, and if there isn't an error, it delete the
> original by the copy with "os.rename" at the end.
>
Hi,
Here is my script :
It propose to replace some words in a file with a regular expression.
It create a copy to write on it, and if there isn't an error, it delete the
original by the copy with "os.rename" at the end.
My problem is, if I work on a huge file, I'll try to avoid to read the file