digitalinteraction / openmovement

Open Movement devices are miniature, embeddable, open source sensors developed at Newcastle University, UK. The source code for the firmware and software is available under a BSD 2-clause license, and the hardware (PCB designs, layouts and schematics), enclosure designs and documentation are available under a Creative Commons 3.0 BY Attribution License.
https://openmovement.dev
145 stars 76 forks source link

Running Python script error #35

Closed sajjadafridi closed 3 years ago

sajjadafridi commented 4 years ago

Hello, I have .cwa file I need to parse and store in SQLite DB. For this, I download the cwa.py script. I passed the input file it creates the SQLite DB file but did not store any values. When I check out the DB file. It contains DateTime, x, y, z columns.

I tried once more by debugging the code. I concluded that after open file, it read the data in binary format which make no sense in if else condition self.fh = open(filename, "rb")

Any help will be appreciated in this regard.

muschellij2 commented 3 years ago

Reproducible example:

git clone --depth=1 https://github.com/digitalinteraction/openmovement
cd openmovement/Software/AX3/cwa-convert/python
wget https://biobank.ctsu.ox.ac.uk/crystal/crystal/examples/accsamp.zip
unzip accsamp.zip
python3 cwa.py accsamp.cwa
cat accsamp.cwa.sqlite 

Pretty much I think the issue is that https://github.com/digitalinteraction/openmovement/blob/master/Software/AX3/cwa-convert/python/cwa.py#L117 and all other string reads fail because of a binary representation of the header object. I think something like:

hdr = header.decode('ascii')

and then

if hdr == "MD":

would work, but I'm not a Python expert.

danielgjackson commented 3 years ago

Apologies for the very late response.

I believe this is fixed in the current version.