pibrary.file

Classes

File

Class to read and write files.

Module Contents

class pibrary.file.File(path: str, *args, **kwargs)[source]

Class to read and write files.

_mode = 'r'[source]
_path[source]
_obj_file = None[source]
read() File[source]

Sets the io mode to read, and path variable to read from.

Returns: Class object to chain with other methods.

write(obj_file: Any) File[source]

Sets the io mode to write, and path variable to write to.

Parameters:

obj_file – Object to save like dict for j

Returns: Class object to chain with other methods.

json(**kwargs) Dict[str, List[str]] | None[source]

Reads or writes json file according to mode set by read/write method.

Parameters:

**kwargs – Keyword arguments for diff read/write like. Eg:nt=4 for json read.

Returns: obj_file if read mode else nothing is returned.

pickle()[source]

Reads or writes pickle file according to mode set by read/write method.

Returns: obj_file if read mode else nothing is returned.

csv(**kwargs) pandas.DataFrame | None[source]

Reads or writes csv file according to mode set by read/write method.

Returns: Dataframe if read mode else nothing is returned.