PyFileIO
Some very basic routines for file IO in Python
Installation
Install via pip3:
pip3 install PyFileIO --user
or from this repo:
git clone https://github.com/mattkjames7/PyFileIO
cd PyFileIO
#either this
python3 setup.py install --user
#or this
python3 setup.py bdist_wheel
pip3 install dist/PyFileIO-X.X.X-py3-none-any.whl
where X.X.X is the version created.
Usage
This module contains a few different methods of loading/saving data.
Loading/Saving Objects
This effectively uses pickle to load and save physical objects, e.g.:
import PyFileIO as pf
#save an object
pf.SaveObject(obj,'/path/to/some/file.bin')
#load an object
obj = pf.LoadObject('/path/to/some/file.bin')
Loading/Saving ASCII Data
Text files may be created and read directly:
#saving text
text = 'some text, can be an array\n or just a single string'
pf.WriteASCIIFile('filename.txt',text)
#reading text
text = pf.ReadASCIIFile('filename.txt')
We can also use ASCII files to load csv files and save data stored in a simple numpy.recarray:
#read a csv file, which contains a header - dtype will be worked out automatically
data = pf.ReadASCIIData('somedata.csv')
#we can also save data
pf.WriteASCIIData('newfile.dat',data)
NOTE: this will only work with simple dtypes
Loading/Saving Binary Data
Pure binary data may be written to files using the following functions:
#open a file
f = open('filename.bin','wb')
#save some stuff
ScalarToFile(x,'int64',f) #save a single scalar integer
ArrayToFile(y,'float32',f) #save a floating point array
ListArrayToFile(z,'int32',f) #save a list of integer arrays
StringToFile(s,f) #save a string to file
#close the file
f.close()
We can also read the data back (remembering to use the correct dtypes!):
#open a file
f = open('filename.bin','rb')
#read the stored data
x = ScalarFromFile('int64',f) #read a single scalar integer
y = ArrayFromFile('float32',f) #read a floating point array
z = ListArrayFromFile('int32',f) #read a list of integer arrays
s = StringFromFile(f) #read a string from file
#close the file
f.close()
Metadata
Release files for PyFileIO 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| PyFileIO-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for PyFileIO-0.0.5-py3-none-any.whl |
Release files / PyFileIO-0.0.5-py3-none-any.whl
| Download URL | PyFileIO-0.0.5-py3-none-any.whl |
|---|---|
| Size | 10.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9924df97bf5a2af6d469d57a053827c758fe64c2a2ff2647ba541705156288ec
|
|
BLAKE2b-256 checksum How to use checksums |
c476c6756c0c71998338b02545579297559d9e1ce0eded0f0121814c42b80b66
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.4
|
Security for PyFileIO 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.