IO

rxsci.io.read(file, mode='r', size=None, encoding=None, open_obj=<built-in function open>)

Reads the content of a file

When provided, the open_obj function must have the following prototype: open(filename, mode, encoding)

Parameters:
  • file – The path of the file to read, or a file object

  • mode – [Optional] how the file must be opened. either ‘r’ to read text or ‘rb’ to read binary

  • size – [Optional] If set file if read by chunks of this size

  • encoding – [Optional] The text encoding to use when reading in text mode

  • open_obj – [Optional] A custom function used to open the provided file.

Returns:

An observable where each item is a chunk of data, or the whole file if no size has been set.

rxsci.io.walk(top, recursive=True)

lists the content of a directory

Returns an observable emitting the files present in top directory and sub-directories.

The source must be an Observable.

Parameters:

top – The directory to walk

Returns:

An Observable emitting string path items

rxsci.io.write(file, mode=None, encoding=None, open_obj=<built-in function open>)

Writes the content of a file

When provided, the open_ibj function must have the following prototype:

open(filename, mode, encoding)

The source must be an Observable.

Parameters:
  • file – the path of the file to read

  • mode – how the file must be opened. either ‘r’ to read text or ‘rb’ to read binary

  • size – [Optional] If set file if read by chunks of this size

  • encoding – [Optional] text encoding to use when reading in text mode

  • open_obj – [Optional] A custom function used to open the provided file.

Returns:

An observable where eeach item is a chunk of data, or the while file if no size has been set.