sc_fileio#
Functions for reading/writing to files, including pickles, JSONs, and Excel.
- Highlights:
sc.save()
/sc.load()
: efficiently save/load any Python object (via pickling)sc.savetext()
/sc.loadtext()
: likewise, for textsc.savejson()
/sc.loadjson()
: likewise, for JSONssc.saveyaml()
/sc.saveyaml()
: likewise, for YAMLsc.thisdir()
: get current foldersc.getfilelist()
: easy way to access globsc.rmpath()
: remove files and folders
Classes
A wrapper for a binary file -- rarely used directly. |
|
A class for reading and writing Excel files in binary format. |
|
An empty class to represent a failed object loading. |
Functions
Load a file that has been saved as a gzipped pickle file, e.g. by |
|
Save any object to disk |
|
Load a file that has been saved as a gzipped pickle file, e.g. by |
|
Save any object to disk |
|
Save a file using zstandard (instead of gzip) compression. |
|
Like |
|
Dump an object to a bytes-like string (rarely used by the user); see |
|
Convenience function for reading a text file |
|
Convenience function for saving a text file -- accepts a string or list of strings; can also save an arbitrary object, in which case it will first convert to a string. |
|
Load the contents of a zip file into a variable |
|
Convenience function for reading a zip file |
|
Create a zip file from the supplied list of files (or less commonly, supplied data) |
|
Alias to |
|
Alias to isinstance(obj, Path). |
|
Return the full path of the current file. |
|
Tiny helper function to get the folder for a file, usually the current file. |
|
Alias for |
|
A shortcut for using |
|
A shortcut for using |
|
Alias for |
|
Takes a potentially Linux- and Windows-unfriendly candidate file name, and returns a "sanitized" version that is more usable. |
|
Alias for |
|
Utility for taking a filename and folder -- or not -- and generating a valid path from them. |
|
Alias for |
|
Remove file(s) and folder(s). |
|
Load data from a file using all known load functions until one works. |
|
This is the main conversion function for Python data-structures into JSON-compatible data structures (note: |
|
This is the main conversion function for Python data-structures into JSON-compatible data structures (note: |
|
Print an object as a JSON |
|
Read JSON from a string |
|
Convenience function for reading a JSON file (or string). |
|
Convenience function for saving to a JSON file. |
|
Read YAML from a string |
|
Convenience function for reading a YAML file (or string). |
|
Convenience function for saving to a YAML file. |
|
Save any Python object to a JSON using jsonpickle. |
|
Open a saved JSON pickle |
|
Load a spreadsheet as a dataframe or a list of lists. |
|
Semi-simple function to save data nicely to Excel. |
Exceptions
A warning raised when unpickling an object fails |
|
An error raised when unpickling an object fails |