Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mdf4reader.py fails to get max len on unicode channels #139

Closed
laurentvm opened this issue Mar 21, 2018 · 11 comments
Closed

mdf4reader.py fails to get max len on unicode channels #139

laurentvm opened this issue Mar 21, 2018 · 11 comments

Comments

@laurentvm
Copy link

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])

@ratal
Copy link
Owner

ratal commented Mar 22, 2018

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.

@laurentvm
Copy link
Author

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.

@laurentvm
Copy link
Author

... Just seen you're in Belgium. I'm too.

@ratal
Copy link
Owner

ratal commented Mar 22, 2018

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 ?

@laurentvm
Copy link
Author

Just an update. Using python 2.7. XLSX fails as mentionned.

Excel file output:
2018-03-23 11_06_18-2018-03-17_13 05 01_ 20121026-005 _all_data-f0018 xlsx - excel

Python output with:
for s in signal: val=yop[s]['data'] print s,val
2018-03-23 10_52_28-giswlx109_99 giswlx109_1 aa30891 - vnc viewer

There is value in the signal but in excel/matlab, there is nothing.

@laurentvm
Copy link
Author

Same with 3.5

@ratal
Copy link
Owner

ratal commented Mar 24, 2018

Try with latest dev branch, it should be fixed

@laurentvm
Copy link
Author

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.
2018-03-26 11_51_18-2018-03-17_13 05 01_ 20121026-005 _all_data-f0018 xlsx - excel

I still have to check to matlab output

@ratal
Copy link
Owner

ratal commented Mar 26, 2018

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

@ratal
Copy link
Owner

ratal commented Jun 2, 2018

No more feedback since while.
If still an issue, you can reopen.

@ratal ratal closed this as completed Jun 2, 2018
@laurentvm
Copy link
Author

Hi, it’s working ok. Thanks for the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants