readers.file_reader: base file reading utilities

class BaseReader(obj)[source]

Common base for FileReader and ZipReader. In fact, it is a very thin wrapper around IO-alike object, to read it line by line and:

  • strip lines transparently

  • ignore BOM (byte-order mark) at the beginning

  • yield line with its number (1-based)

  • support encoding change on the fly:

    for line in reader:
        # do something
        reader.reset_encoding('UTF-8')
        # ..continue to read from the same line
    
class FileReader(path, encoding='Windows-1252')[source]

Reader implementation for simple filesystem file.

class ZipReader(zip_obj, encoding='Windows-1252')[source]

Reader implementation for file inside zip archive.