Muscat.IO.ReaderBase module¶
Base reader object from which all the readers of Muscat
- class ReaderBase(fileName: str = '')[source]¶
Bases:
object
Base class for all the readers
- Peek(length: int = 1) str [source]¶
Read a length number of chars without advancing the file
- Parameters:
length (int, optional) – number of chars to read, by default 1
- Returns:
a string of size length the the next chars in the buffer
- Return type:
str
- PeekLine() str [source]¶
Read a line without advancing
- Returns:
the next line in the input buffer
- Return type:
str
- RawRead(cpt: int, withError: bool = False) bytes [source]¶
Read raw data (binary from the input buffer )
- Parameters:
cpt (int) – number of char to read
withError (bool, optional) – raise EOFError if not able to read cpt chars from the buffer, by default False
- Returns:
the raw data
- Return type:
bytes
- Raises:
EOFError – _description_
- ReadCleanLine() str | None [source]¶
Return the next (non comment) line in the file
- Returns:
Return the next clean line
- Return type:
str
- ReadData(cpt: int, datatype: Type) ndarray [source]¶
Read data cpt instances of type datatype from the input buffer first try to use the np.fromfile for speed if it fail will try np.frombuffer
- Parameters:
cpt (int) – number of data to read
datatype (Type) – data type
- Returns:
the data read
- Return type:
np.ndarray
- Seek(pos: int) None [source]¶
Move pointer to the internal file descriptor to the position pos
- Parameters:
cpt (int) – _description_
- SetBinary(binary: bool = True) None [source]¶
Sets the binary status of the file to read
- Parameters:
binary (bool, optional) – if True, sets the file to read as binary, by default True
- SetFileName(fileName: str) None [source]¶
Sets the name of file to read. if fileName is “PIPE” then call self.SetReadFromPipe()
- Parameters:
fileName (str) – file name to set