Command lines

  1. extract the first lines of a file
  2. extract the last lines of a file

extract the first lines of a file

Extracts the first line of a file.

file_head_cli –help

usage: file_head [-h] [-f FILENAME] [-n NBLINE] [-e ENCODING] [-er ERRORS]

Extracts the first *nbline* of a file (assuming it is text file).

optional arguments:
  -h, --help            show this help message and exit
  -f FILENAME, --filename FILENAME
                        filename (default: None)
  -n NBLINE, --nbline NBLINE
                        number of lines (default: 10)
  -e ENCODING, --encoding ENCODING
                        encoding (default: utf8)
  -er ERRORS, --errors ERRORS
                        see open (default: strict)

(original entry : head_cli.py:docstring of pyensae.cli.head_cli.file_head_cli, line 6)

extract the last lines of a file

Extracts the first line of a file.

file_tail_cli –help

usage: file_tail [-h] [-f FILENAME] [-n NBLINE] [-e ENCODING] [-t THRESHOLD]
                 [-er ERRORS]

Extracts the first nbline of a file (assuming it is text file). The line
marked as *A* has an issue because the cursor could fall on a character (=
byte) in the middle of a character if the file is encoded in utf-8 character.
The next line fails. That's why we try again by moving the cursor by one
character (see line B). The first returned line may be incomplete.

optional arguments:
  -h, --help            show this help message and exit
  -f FILENAME, --filename FILENAME
                        filename (default: None)
  -n NBLINE, --nbline NBLINE
                        number of lines (default: 10)
  -e ENCODING, --encoding ENCODING
                        encoding (default: utf8)
  -t THRESHOLD, --threshold THRESHOLD
                        if the file size is above, it will not read the
                        beginning (default: 16384)
  -er ERRORS, --errors ERRORS
                        see open (default: strict)

(original entry : tail_cli.py:docstring of pyensae.cli.tail_cli.file_tail_cli, line 6)