ghammad / pyActigraphy

Python-based open source package for actigraphy data analysis
https://ghammad.github.io/pyActigraphy
GNU General Public License v3.0
136 stars 27 forks source link

Support different file encodings for RPX files #134

Closed ugGit closed 1 year ago

ugGit commented 1 year ago

Objective

Read RPX files having a different encoding than utf-8 (e.g., cp1252).

Current Behavior

>>> pyActigraphy.io.read_raw_rpx(rpx_file_in_cp1252, language='FR')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 15: invalid start byte

Expected Behavior

>>> pyActigraphy.io.read_raw_rpx(rpx_file_in_cp1252, language='FR', file_encoding='cp1252')
<pyActigraphy.io.rpx.rpx.RawRPX object at 0x000001E8E0B53100>

Suggested Solution

Add an additional file_encoding argument to read_raw_rpx(). The argument is then subsequentially passed to all methods called in the RawRPX class.