Classes
FileDataReader(filename) | A reader that can read data from a file |
FileIO | file(name: str[, mode: str]) -> file IO object |
Bases: spinnman.data.abstract_data_reader.AbstractDataReader
A reader that can read data from a file
Parameters: | filename (str) – The file to read |
---|---|
Raises spinnman.exceptions.SpinnmanIOException: | |
If the file cannot found or opened for reading |
Methods
close() | Closes the file |
read(n_bytes) | See spinnman.data.abstract_data_reader.AbstractDataReader.read() |
readall() | See spinnman.data.abstract_data_reader.AbstractDataReader.readall() |
readinto(data) | See spinnman.data.abstract_data_reader.AbstractDataReader.readinto() |
Detailed Methods
Closes the file
Returns: | Nothing is returned: |
---|---|
Return type: | None |
Raises spinnman.exceptions.SpinnmanIOException: | |
If the file cannot be closed |
See spinnman.data.abstract_data_reader.AbstractDataReader.read()
See spinnman.data.abstract_data_reader.AbstractDataReader.readinto()
Bases: _io._RawIOBase
file(name: str[, mode: str]) -> file IO object
Open a file. The mode can be ‘r’, ‘w’ or ‘a’ for reading (default), writing or appending. The file will be created if it doesn’t exist when opened for writing or appending; it will be truncated when opened for writing. Add a ‘+’ to the mode to allow simultaneous reading and writing.
Attributes
closed | True if the file is closed |
closefd | True if the file descriptor will be closed |
mode | String giving the file mode |
next | x.next() -> the next value, or raise StopIteration |
closed | True if the file is closed |
next | x.next() -> the next value, or raise StopIteration |
closed | True if the file is closed |
next | x.next() -> the next value, or raise StopIteration |
Methods
close(() -> None. Close the file.) | A closed file cannot be used for further I/O operations. |
fileno(() -> int. “file descriptor”.) | This is needed for lower-level file interfaces, such the fcntl module. |
flush | Flush write buffers, if applicable. |
isatty(...) | |
read(...) | Only makes one system call, so less data may be returned than requested In non-blocking mode, returns None if no data is available. |
readable(...) | |
readall(...) | In non-blocking mode, returns as much as is immediately available, or None if no data is available. |
readinto(() -> Same as RawIOBase.readinto().) | |
readline | Read and return a line from the stream. |
readlines | Return a list of lines from the stream. |
seek((offset: int[, ...) | Argument offset is a byte count. |
seekable(...) | |
tell(() -> int. Current file position) | |
truncate(...) | Size defaults to the current file position, as returned by tell().The current file position is changed to the value of size. |
writable(...) | |
write(...) | Only makes one system call, so not all of the data may be written. |
writelines | |
close(() -> None. Close the file.) | A closed file cannot be used for further I/O operations. |
fileno(() -> int. “file descriptor”.) | This is needed for lower-level file interfaces, such the fcntl module. |
flush | Flush write buffers, if applicable. |
isatty(...) | |
read(...) | Only makes one system call, so less data may be returned than requested In non-blocking mode, returns None if no data is available. |
readable(...) | |
readall(...) | In non-blocking mode, returns as much as is immediately available, or None if no data is available. |
readline | Read and return a line from the stream. |
readlines | Return a list of lines from the stream. |
seek((offset: int[, ...) | Argument offset is a byte count. |
seekable(...) | |
tell(() -> int. Current file position) | |
truncate(...) | Size defaults to the current file position, as returned by tell().The current file position is changed to the value of size. |
writable(...) | |
writelines | |
close(() -> None. Close the file.) | A closed file cannot be used for further I/O operations. |
fileno(() -> int. “file descriptor”.) | This is needed for lower-level file interfaces, such the fcntl module. |
flush | Flush write buffers, if applicable. |
isatty(...) | |
readable(...) | |
readline | Read and return a line from the stream. |
readlines | Return a list of lines from the stream. |
seek((offset: int[, ...) | Argument offset is a byte count. |
seekable(...) | |
tell(() -> int. Current file position) | |
truncate(...) | Size defaults to the current file position, as returned by tell().The current file position is changed to the value of size. |
writable(...) | |
writelines |
Detailed Methods
A closed file cannot be used for further I/O operations. close() may be called more than once without error. Changes the fileno to -1.
This is needed for lower-level file interfaces, such the fcntl module.
Flush write buffers, if applicable.
This is not implemented for read-only and non-blocking streams.
Only makes one system call, so less data may be returned than requested In non-blocking mode, returns None if no data is available. On end-of-file, returns ‘’.
In non-blocking mode, returns as much as is immediately available, or None if no data is available. On end-of-file, returns ‘’.
Read and return a line from the stream.
If limit is specified, at most limit bytes will be read.
The line terminator is always b’n’ for binary files; for text files, the newlines argument to open can be used to select the line terminator(s) recognized.
Return a list of lines from the stream.
hint can be specified to control the number of lines read: no more lines will be read if the total size (in bytes/characters) of all lines so far exceeds hint.
Argument offset is a byte count. Optional argument whence defaults to 0 (offset from start of file, offset should be >= 0); other values are 1 (move relative to current position, positive or negative), and 2 (move relative to end of file, usually negative, although many platforms allow seeking beyond the end of a file). Note that not all file objects are seekable.
Size defaults to the current file position, as returned by tell().The current file position is changed to the value of size.
Only makes one system call, so not all of the data may be written. The number of bytes actually written is returned.
A closed file cannot be used for further I/O operations. close() may be called more than once without error. Changes the fileno to -1.
This is needed for lower-level file interfaces, such the fcntl module.
Flush write buffers, if applicable.
This is not implemented for read-only and non-blocking streams.
Only makes one system call, so less data may be returned than requested In non-blocking mode, returns None if no data is available. On end-of-file, returns ‘’.
In non-blocking mode, returns as much as is immediately available, or None if no data is available. On end-of-file, returns ‘’.
Read and return a line from the stream.
If limit is specified, at most limit bytes will be read.
The line terminator is always b’n’ for binary files; for text files, the newlines argument to open can be used to select the line terminator(s) recognized.
Return a list of lines from the stream.
hint can be specified to control the number of lines read: no more lines will be read if the total size (in bytes/characters) of all lines so far exceeds hint.
Argument offset is a byte count. Optional argument whence defaults to 0 (offset from start of file, offset should be >= 0); other values are 1 (move relative to current position, positive or negative), and 2 (move relative to end of file, usually negative, although many platforms allow seeking beyond the end of a file). Note that not all file objects are seekable.
Size defaults to the current file position, as returned by tell().The current file position is changed to the value of size.
A closed file cannot be used for further I/O operations. close() may be called more than once without error. Changes the fileno to -1.
This is needed for lower-level file interfaces, such the fcntl module.
Flush write buffers, if applicable.
This is not implemented for read-only and non-blocking streams.
Read and return a line from the stream.
If limit is specified, at most limit bytes will be read.
The line terminator is always b’n’ for binary files; for text files, the newlines argument to open can be used to select the line terminator(s) recognized.
Return a list of lines from the stream.
hint can be specified to control the number of lines read: no more lines will be read if the total size (in bytes/characters) of all lines so far exceeds hint.
Argument offset is a byte count. Optional argument whence defaults to 0 (offset from start of file, offset should be >= 0); other values are 1 (move relative to current position, positive or negative), and 2 (move relative to end of file, usually negative, although many platforms allow seeking beyond the end of a file). Note that not all file objects are seekable.
Size defaults to the current file position, as returned by tell().The current file position is changed to the value of size.