Skip to main content

binfilepy

Software library to read and write binary file (.adibin format).

Example to write a binary file:

from binfilepy import BinFile
from binfilepy import CFWBINARY
from binfilepy import CFWBCHANNEL

with BinFile(filename, "w") as f:
    header = CFWBINARY()
    header.setValue(1.0 / 240.0, 2019, 1, 28, 8, 30, 0.0, 0.0, 2, 0)
    f.setHeader(header)
    channel1 = CFWBCHANNEL()
    channel1.setValue("I", "mmHg", 1.0, 0.0)
    f.addChannel(channel1)
    channel2 = CFWBCHANNEL("II", "mmHg", 1.0, 0.0)
    f.addChannel(channel2)
    chanData = []
    d1 = [1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1]
    d2 = [8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8]
    chanData.append(data1)
    chanData.append(data2)
    f.writeHeader()
    f.writeChannelData(chanData)
    f.updateSamplesPerChannel(16, True)

Example to read a binary file:

from binfilepy import BinFile

with BinFile(filename, "r") as f:
    # You must read header first before you can read channel data
    f.readHeader()
    # readChannelData() supports reading in random location (Ex: Read 10 secs of data at 1 min mark)
    data = f.readChannelData(offset=60, length=10, useSecForOffset=True, useSecForLength=True)

File open mode

Currently, there are three modes to open a file:

  • "w": For writing to a new file. You need to make sure the file doesn't exist.
  • "r": For reading from an existing file. You need to make sure the file exists.
  • "r+": For appending data to an existing file. You need to make sure the file exists.

You can use either syntax:

with BinFile(filename, "w") as f:
    ...
    ...

or

f = BinFile(filename, "w")
f.open()
...
...
f.close()

Download files

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

Source Distribution

binfilepy-0.1.8.tar.gz (7.6 kB view details)

Uploaded Source

File details

Details for the file binfilepy-0.1.8.tar.gz.

File metadata

  • Download URL: binfilepy-0.1.8.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for binfilepy-0.1.8.tar.gz
Algorithm Hash digest
SHA256 764f16f02a998ed605c4051aeb1f82307551ed045a6aab913b28d76f23e9d6a4
MD5 ea5e06a6423a46dbcb542b51003df2e1
BLAKE2b-256 738bbd0977cdf1b396d2a14d3744d805aada66abfb891a67a4ec40dd23566c70

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.8 This release

1 file

0.1.7

1 file

0.1.6

1 file

0.1.5

1 file

0.1.4

1 file

0.1.3

1 file

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

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