Skip to content
Flav20 edited this page Nov 8, 2024 · 6 revisions

file operations

Table of contents

Intro

This package allows to read/parse a file in python. When should we use this package? If your file is really big (> 100 000 lines), because if you want to parse a file in python you'll write:

f = open("my_file", "r")
buffer: str = f.read()
...

or:

f = open("my_file", "r")
for line in f.readlines():
    ...
  • With the first one, there is a memory issue because you must save the entire file into a buffer.
  • With the second one, there is a time issue because a loop can be very slow in python.

So, this package gives tools to easily read a file with efficiently. It's based on Linux tools like grep, sed, cat, head, tail and tested with them.

Clone this wiki locally