Closed laurentvm closed 6 years ago
Hi Laurent,
Can you inform what is python version you use ? unicode is big change between 2.7 and 3.x
But I guess you use 2.7 according to my tests, len(str(u'ö$oi'))
will fail only for python 2.7
However, len(u'ö$oi')
will work properly for both python version --> can you try without the str() ?
Actually, I do nto think len(repr(ref).encode('utf-8'))
gives the right length.
Hi,
Yes it was with python 2.7. I can try with 3.x if you need too. I will try with len only.
By the way, the file I got (mf4) is full of unicode. I'm not sure but it seems that it fails to export to matlab/xlsx with this unicode values.
For instance, I have a numpy array with \u'0' values or \u'Init' which was a pain to output from the numpy array. I will continue my investigation. Unfortunately, I cannot share the file with you but I way look if I can replicate the structure to share it.
... Just seen you're in Belgium. I'm too.
mf4 is by specification only unicode and using xml for metadata, this was major change from 3.x to 4.x If there is an error with the matlab export, maybe we should then rather focus on this method to improve its robustness ?
Just an update. Using python 2.7. XLSX fails as mentionned.
Excel file output:
Python output with:
for s in signal: val=yop[s]['data'] print s,val
There is value in the signal but in excel/matlab, there is nothing.
Same with 3.5
Try with latest dev branch, it should be fixed
Hi, just tested with python 3, the excel gives much more information now. Great!
I have many signals named t
, before your code were completing the header name by t
, t_1
, t_2
, ...
Now it append the suffix twice.
I still have to check to matlab output
This could be normal behaviour. If you have unsorted data, like several channel groups per datagroup, 't' channel could be also present several time, so datagroup number and channelgroup numbers are appended to duplicated channel names
No more feedback since while. If still an issue, you can reopen.
Hi, it’s working ok. Thanks for the fix
Line 1873 of mdf4reader.py
maxlen = max([len(str(ref)) for ref in cc_ref])
fails if ref is unicode. Had to change to this to export to Matlab.maxlen = max([len(repr(ref).encode('utf-8')) for ref in cc_ref])