{"action":"created","issue":{"url":"https://api.github.com/repos/ratal/mdfreader/issues/58","repository_url":"https://api.github.com/repos/ratal/mdfreader","labels_url":"https://api.github.com/repos/ratal/mdfreader/issues/58/labels{/name}","comments_url":"https://api.github.com/repos/ratal/mdfreader/issues/58/comments","events_url":"https://api.github.com/repos/ratal/mdfreader/issues/58/events","html_url":"https://github.com/ratal/mdfreader/issues/58","id":232694416,"number":58,"title":"Error importing MDF4 files with channel names that start with '#' (But only when using a channelList)","user":{"login":"mattdreisbach","id":14638672,"avatar_url":"https://avatars3.githubusercontent.com/u/14638672?v=3","gravatar_id":"","url":"https://api.github.com/users/mattdreisbach","html_url":"https://github.com/mattdreisbach","followers_url":"https://api.github.com/users/mattdreisbach/followers","following_url":"https://api.github.com/users/mattdreisbach/following{/other_user}","gists_url":"https://api.github.com/users/mattdreisbach/gists{/gist_id}","starred_url":"https://api.github.com/users/mattdreisbach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattdreisbach/subscriptions","organizations_url":"https://api.github.com/users/mattdreisbach/orgs","repos_url":"https://api.github.com/users/mattdreisbach/repos","events_url":"https://api.github.com/users/mattdreisbach/events{/privacy}","received_events_url":"https://api.github.com/users/mattdreisbach/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2017-05-31T20:59:38Z","updated_at":"2017-06-09T08:57:25Z","closed_at":"2017-06-09T08:57:25Z","body":"When I import my mdf4 data using\r\n`yop = mdfreader.mdf(filename)`\r\neverything works great but it takes a long time to process all the data\r\nwhen I use:\r\n```\r\nchannelList = ['example','#latitude','of','#data']\r\nyop = mdfreader.mdf()\r\nyop.read(fileName=filename, channelList=channelList)\r\n```\r\nThe program fails on the channels that start with '#' symbols\r\nhere is the traceback:\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"C:\\Users\\420278\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\numpy\\core\\records.py\", line 444, in __getattribute__\r\n    res = fielddict[attr][:2]\r\nKeyError: 'latitude'\r\n```\r\n\r\nhere is an additional traceback of an exception that occurs during the handeling of the one above,\r\n\r\n```\r\n  File \"C:\\Users\\420278\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\mdfreader\\mdfreader.py\", line 362, in read\r\n    self.read4(self.fileName, info, multiProc, channelList, convertAfterRead, filterChannelNames=False)\r\n  File \"C:\\Users\\420278\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\mdfreader\\mdf4reader.py\", line 1393, in read4\r\n    temp = buf[recordID]['data'].__getattribute__(recordName)  # extract channel vector\r\n  File \"C:\\Users\\420278\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\numpy\\core\\records.py\", line 446, in __getattribute__\r\n    raise AttributeError(\"recarray has no attribute %s\" % attr)\r\nAttributeError: recarray has no attribute latitude\r\n```\r\nOnce again, this problem does not happen when importing without a channelList and it prints out the proper names when calling yop.keys(). \r\ncalling:\r\n```\r\n    info=mdfreader.mdfinfo()\r\n    print(info.listChannels(filename))\r\n```\r\nproduces the expected output with properly formatted channel names\r\n \r\nThe problem is somehow related to your function:\r\n`_gen_valid_identifier`\r\nin mdf.py\r\nI was able to implement a workaround by adding\r\n\r\n`or '#'`\r\n\r\nto the sanitizer, resulting in the code below (around line 638 of mdf.py):\r\n```\r\ndef _gen_valid_identifier(seq):\r\n    # get an iterator\r\n    itr = iter(seq)\r\n    # pull characters until we get a legal one for first in identifer\r\n    for ch in itr:\r\n        if ch == '_' or '#' or ch.isalpha():\r\n            yield ch\r\n            break\r\n        elif ch.isdigit():\r\n            itr = chain(itr,ch)\r\n\r\n    # pull remaining characters and yield legal ones for identifier\r\n    for ch in itr:\r\n        if ch == '_' or '#' or ch.isalpha() or ch.isdigit():\r\n            yield ch\r\n\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ratal/mdfreader/issues/comments/307335007","html_url":"https://github.com/ratal/mdfreader/issues/58#issuecomment-307335007","issue_url":"https://api.github.com/repos/ratal/mdfreader/issues/58","id":307335007,"user":{"login":"ratal","id":5404948,"avatar_url":"https://avatars2.githubusercontent.com/u/5404948?v=3","gravatar_id":"","url":"https://api.github.com/users/ratal","html_url":"https://github.com/ratal","followers_url":"https://api.github.com/users/ratal/followers","following_url":"https://api.github.com/users/ratal/following{/other_user}","gists_url":"https://api.github.com/users/ratal/gists{/gist_id}","starred_url":"https://api.github.com/users/ratal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ratal/subscriptions","organizations_url":"https://api.github.com/users/ratal/orgs","repos_url":"https://api.github.com/users/ratal/repos","events_url":"https://api.github.com/users/ratal/events{/privacy}","received_events_url":"https://api.github.com/users/ratal/received_events","type":"User","site_admin":false},"created_at":"2017-06-09T08:57:24Z","updated_at":"2017-06-09T08:57:24Z","body":"Thanks for the proposal, my first donation :)\r\nmy paypal account is linked to my gmail account: aymeric.rateau@gmail.com\r\nRegarding pip, I would like to fix the last regressions I introduced by tackling the python identifier character limitation applied to reacarray (this issue) ; several issues ongoing, once solved I will push new pip version."}}
{"actor":{"display_login":"ratal"}}