Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Python module which loads and saves data structures based on the file extension.
pip install loadsave
import loadsave
data = loadsave.load(filename)
... manipulating data ...
loadsave.save(data, filename)
Saving data can be a bit unintuitive.
csv
requires data to be a list of dictionarieswav
requires data to be a tuple or list of the form (y,sr)
exactly how it would be returned by load('example.wav')
This module attempts to follow a generic procedure for reading and writing common data storage formats using only the file extension for guidance.
The motivation here is as follows; Most of the time, the most generic approach to opening a file will work. It's may not be the most computationaly efficient way, but if loading time is not a bottleneck for your workflow, you might as well spend your time manipulating the data as opposed figuring out how to load it into python. The goal of Datastore is to make implementing these generic approaches as fast as possible. If it doesn't work, well at least you didn't waste much time. Otherwise, you just skipped a monotonous task and can get on with real work.
import loadsave
d = [{'id': [1,2,3,4],'otherID':[4,3,2,1]}]
# save this dict as a pickle
loadsave.save(d, 'test.pkl')
'test.pkl'
can be replaced with 'test.json'
, or 'test.csv'
. Attempting to save it to 'test.wav'
will return an error, because d
is not an acceptable format for an audio waveform.
However, if d = [0,1,2,3,4]
you could call loadsave.save((d,44100),'test.wav')
. csv
s require a list of dictionaries, so trying to save this as a csv will fail
loadsave.load('example.wav')
dict
, list
, str
, int
, float
, bool
, and None
FAQs
One-line loading and saving to/from various file formats (csv, wav, pkl, json)
We found that loadsave demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.