file_io¶
Functions
|
Append data to a jsonl file. |
|
Load both the json and pickle files and return the object from the json file |
|
Customized Load a JSON file and deserialize it. |
|
Load a jsonl file and return a list of dictionaries. |
|
Load the object from a pickle file. |
Standard Load a JSON file and deserialize it. |
|
|
Save the object to both a json and a pickle file. |
|
Save the object to a csv file. |
|
Customized 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]¶
Customized Save the object to a json file.
Support Set. We encourage users first save the data as DataClass using to_dict, and then load it back to DataClass using from_dict.
- 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) Any [source]¶
Customized Load a JSON file and deserialize it.
- Parameters:
f (str) – The file name of the JSON file to load.
- Returns:
The deserialized Python object.
- Return type:
Any
- load_standard_json(f: str) Any [source]¶
Standard Load a JSON file and deserialize it. :param f: The file name of the JSON file to load. :type f: str
- Returns:
The deserialized Python object.
- Return type:
Any
- 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.