Skip to main content

A python implementation of the flat-file streaming database

Project description

Objective

A python implementation of the FSDB flat-file streaming database.

Installation

Using pip:

pip3 install pyfsdb

Or manually:

git clone git@github.com:gawseed/pyfsdb.git
cd pyfsdb
python3 setup.py build
python3 setup.py install

Example Usage

The FSDB file format contains headers and footers that supplement the data within a file. The most common separator is tab-separated, but can wrap CSVs and other datatypes (see the FSDB documentation for full details). The file also contains footers that trace all the piped commands that were used to create a file, thus documenting the history of its creation within the metadata in the file.

Example pyfsdb code for reading a file

Reading in row by row:

import pyfsdb
db = pyfsdb.Fsdb("myfile.fsdb")
print(db.column_names)
for row in db:
    print(row)

Example FSDB file

#fsdb -F t col1 two andthree
1	key1	42.0
2	key2	123.0

Example writing to an FSDB formatted file.

import pyfsdb
db = pyfsdb.Fsdb(out_file="myfile.fsdb")
db.out_column_names=('one', 'two')
db.append([4, 'hello world'])
db.close()

Read below for further usage details.

Installation

pip3 install pyfsdb

Additional Usage Details

The real power of the FSDB comes from the build up of tool-suites that all interchange FSDB formatted files. This allows chaining multiple commands together to achieve a goal. Though the original base set of tools are in perl, you don't need to know perl for most of them.

Let's create a ./mydemo command:

import sys, pyfsdb

db = pyfsdb.Fsdb(file_handle=sys.stdin, out_file_handle=sys.stdout)
value_column = db.get_column_number('value')

for row in db:     # reads a row from the input stream
    row[value_column] = float(row[value_column]) * 2
    db.append(row) # sends the row to the output stream

db.close()

And then feed it this file:

#fsdb -F t col1 value
1	42.0
2	123.0

We can run it thus'ly:

# cat test.fsdb | ./mydemo
#fsdb -F t col1 value
1	84.0
2	246.0
#   | ./test.py

Or chain it together with multiple FSDB commands:

# cat test.fsdb | ./mydemo | dbcolstats valueq
cat test.fsdb | PYTHONPATH=pyfsdb python3 ./test.py | dbcolstats value | dbcol mean stddev sum min max | dbfilealter -R C
#fsdb -R C mean stddev sum min max
mean: 165
stddev: 114.55
sum: 330
min: 84
max: 246

#   | ./test.py
#   | dbcolstats value
#   | dbcol mean stddev sum min max
#   | dbfilealter -R C

See also

The FSDB website and manual page for the original perl module:

https://www.isi.edu/~johnh/SOFTWARE/FSDB/

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

pyfsdb-1.1.17.tar.gz (24.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyfsdb-1.1.17-py3-none-any.whl (71.4 kB view details)

Uploaded Python 3

File details

Details for the file pyfsdb-1.1.17.tar.gz.

File metadata

  • Download URL: pyfsdb-1.1.17.tar.gz
  • Upload date:
  • Size: 24.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.3 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.9.1

File hashes

Hashes for pyfsdb-1.1.17.tar.gz
Algorithm Hash digest
SHA256 1302803155e91978e8aa6181dd4dd2603daefcd69975846dc72d5f026904647c
MD5 7264fbf96a57c9a0a588e67852919e7a
BLAKE2b-256 708540eb6e23df4d72cc1e9d09603c92dff45f518fced5398a563721240c01e3

See more details on using hashes here.

File details

Details for the file pyfsdb-1.1.17-py3-none-any.whl.

File metadata

  • Download URL: pyfsdb-1.1.17-py3-none-any.whl
  • Upload date:
  • Size: 71.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.3 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.9.1

File hashes

Hashes for pyfsdb-1.1.17-py3-none-any.whl
Algorithm Hash digest
SHA256 33e6943679e2ab1ecc536d7df4c55fe22bf96ddb553b7ba88fd577b9c150ed6f
MD5 c65f88c226297418c6fe927f0f6bbc29
BLAKE2b-256 9aa2dfad4dabf1d760ec6471cdbd66212fabc2cffafdccdf07acb917cc3d478c

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