Skip to main content

A simple package that allows creating a pickles dataset and fast random access

Project description

RA Pickles

A simple package to create and access datasets based on python objects using pickles. A dataset will be represented by a directory. And the files in the directory contain the data. As file identifiers are randomly generated, files from two dataset folders can be added to each other create a larger dataset.

Example

First import all the packages

from ra_pickles import RandomAccessPicklesReader, RandomAccessPicklesWriter
import shutil
import os
import numpy as np

So to create a dataset in test_folder, use the following code. 100 here specifies number of dataset samples in each file. If there are more than 100 files, multiple files will be created.

fold = 'test_folder'
dataset = RandomAccessPicklesWriter(100, fold)

Now entries to the dataset can be added as follows:

for i in range(30):
    d = np.ones(4) * i
    dataset.add(d)
dataset.close()

Here, 30 numpy arrays have been added.

To access contents in the dataset, use the following code:

dataset = RandomAccessPicklesReader(fold)
print("Total", dataset.get_total())

print("Trying to retreive")
for i in range(30):
    print("Retrieving",i)
    a = dataset.get_nth(i)
    print(i, a[0])

Good luck!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ra_pickles-0.8.3.tar.gz (4.1 kB view details)

Uploaded Source

File details

Details for the file ra_pickles-0.8.3.tar.gz.

File metadata

  • Download URL: ra_pickles-0.8.3.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for ra_pickles-0.8.3.tar.gz
Algorithm Hash digest
SHA256 9e0abdd8c3b75287e327c4a7e0807910742f2de45436629661822407c9eff570
MD5 1d263b5c8085cd4de513ee5339c2cdc7
BLAKE2b-256 e7e35daf15dfe5c2a33247743bfb496b28d49e5f1ac0ee5c29711ae6369196e0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page