file_io#
Functions
|
Append data to a jsonl file. |
|
Load both the json and pickle files and return the object from the json file |
|
Load the object from a json file. |
|
Load a jsonl file and return a list of dictionaries. |
|
Load the object from a pickle file. |
|
Save the object to both a json and a pickle file. |
|
Save the object to a csv file. |
|
Save the object to a json file. |
|
Save the object to a pickle file. |
|
Write a list of dictionaries to a jsonl file. |
- save_json(obj: Mapping[str, Any], f: str = 'task.json') None [source]#
Save the object to a json file.
- Parameters:
obj (Mapping[str, Any]) – The object to be saved.
f (str, optional) – The file name. Defaults to “task”.
- save_csv(obj: List[Dict[str, Any]], f: str = 'task.csv', fieldnames: List[str] = None) None [source]#
Save the object to a csv file.
- Parameters:
obj (List[Dict[str, Any]]) – The object to be saved.
f (str, optional) – The file name. Defaults to “task”.
- save_pickle(obj: Mapping[str, Any], f: str = 'task.pickle') None [source]#
Save the object to a pickle file.
- Parameters:
obj (Mapping[str, Any]) – The object to be saved.
f (str, optional) – The file name. Defaults to “task”.
- save(obj: Mapping[str, Any], f: str = 'task') None [source]#
Save the object to both a json and a pickle file.
We save two versions of the object: - task.json: the object itself with Parameter serialized to dict - task.pickle: the object itself with Parameter as is
- load_json(f: str = 'task.json') Mapping[str, Any] | None [source]#
Load the object from a json file.
- Parameters:
f (str, optional) – The file name. Defaults to “task”.
- load_pickle(f: str = 'task.pickle') Mapping[str, Any] | None [source]#
Load the object from a pickle file.
- Parameters:
f (str, optional) – The file name. Defaults to “task”.
- load(f: str = 'task') Mapping[str, Any] | None [source]#
Load both the json and pickle files and return the object from the json file
- Parameters:
f (str, optional) – The file name. Defaults to “task”.
- load_jsonl(f: str = None) List[Dict[str, Any]] [source]#
Load a jsonl file and return a list of dictionaries.
- Parameters:
f (str, optional) – The file name. Defaults to None.