{"action":"closed","issue":{"url":"https://api.github.com/repos/biocore/biom-format/issues/614","labels_url":"https://api.github.com/repos/biocore/biom-format/issues/614/labels{/name}","comments_url":"https://api.github.com/repos/biocore/biom-format/issues/614/comments","events_url":"https://api.github.com/repos/biocore/biom-format/issues/614/events","html_url":"https://github.com/biocore/biom-format/issues/614","id":62217929,"number":614,"title":"Empty file causes non-informative error","user":{"login":"ElDeveloper","id":375307,"avatar_url":"https://avatars.githubusercontent.com/u/375307?v=3","gravatar_id":"","url":"https://api.github.com/users/ElDeveloper","html_url":"https://github.com/ElDeveloper","followers_url":"https://api.github.com/users/ElDeveloper/followers","following_url":"https://api.github.com/users/ElDeveloper/following{/other_user}","gists_url":"https://api.github.com/users/ElDeveloper/gists{/gist_id}","starred_url":"https://api.github.com/users/ElDeveloper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElDeveloper/subscriptions","organizations_url":"https://api.github.com/users/ElDeveloper/orgs","repos_url":"https://api.github.com/users/ElDeveloper/repos","events_url":"https://api.github.com/users/ElDeveloper/events{/privacy}","received_events_url":"https://api.github.com/users/ElDeveloper/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/biocore/biom-format/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-03-16T21:43:59Z","updated_at":"2015-03-19T03:23:21Z","closed_at":"2015-03-19T03:23:21Z","body":"Trying to load an empty file, yields a rather non-informattive error, it would be really nice if a more informative error was raised instead, though I understand if this is out of the scope of the parsers.\r\n\r\nTo reproduce in your machine try the following:\r\n\r\n```\r\n(qiime-dev)yoshikivazquezbaeza:16s$ touch lolercoaster.biom # this file didn't exist\r\n(qiime-dev)yoshikivazquezbaeza:16s$ biom summarize-table -i lolercoaster.biom \r\n```\r\n\r\nWhich causes the following error:\r\n\r\n```python\r\nTraceback (most recent call last):\r\n  File \"/Users/yoshikivazquezbaeza/.virtualenvs/qiime-dev/bin/pyqi\", line 184, in <module>\r\n    optparse_main(cmd_obj, argv[1:])\r\n  File \"/Users/yoshikivazquezbaeza/.virtualenvs/qiime-dev/lib/python2.7/site-packages/pyqi/core/interfaces/optparse/__init__.py\", line 275, in optparse_main\r\n    result = optparse_cmd(local_argv[1:])\r\n  File \"/Users/yoshikivazquezbaeza/.virtualenvs/qiime-dev/lib/python2.7/site-packages/pyqi/core/interface.py\", line 38, in __call__\r\n    cmd_input = self._input_handler(in_, *args, **kwargs)\r\n  File \"/Users/yoshikivazquezbaeza/.virtualenvs/qiime-dev/lib/python2.7/site-packages/pyqi/core/interfaces/optparse/__init__.py\", line 194, in _input_handler\r\n    self._optparse_input[optparse_clean_name])\r\n  File \"/Users/yoshikivazquezbaeza/.virtualenvs/qiime-dev/lib/python2.7/site-packages/biom/interfaces/optparse/input_handler.py\", line 56, in load_biom_table_with_file_contents\r\n    table = parse_biom_table(biom_f)\r\n  File \"/Users/yoshikivazquezbaeza/.virtualenvs/qiime-dev/lib/python2.7/site-packages/biom/parse.py\", line 312, in parse_biom_table\r\n    t = Table.from_tsv(fp, None, None, lambda x: x)\r\n  File \"/Users/yoshikivazquezbaeza/.virtualenvs/qiime-dev/lib/python2.7/site-packages/biom/table.py\", line 3773, in from_tsv\r\n    t_md_name) = Table._extract_data_from_tsv(lines, **kwargs)\r\n  File \"/Users/yoshikivazquezbaeza/.virtualenvs/qiime-dev/lib/python2.7/site-packages/biom/table.py\", line 3864, in _extract_data_from_tsv\r\n    for index in range(0, data_start + 1):\r\nUnboundLocalError: local variable 'data_start' referenced before assignment\r\n```\r\n\r\n-----\r\n\r\nI've also been able to reproduce this using the `load_table` function only:\r\n\r\n```python\r\nIn [1]: from biom import load_table\r\n\r\nIn [2]: bt = load_table('lolercoaster.biom')\r\n---------------------------------------------------------------------------\r\nUnboundLocalError                         Traceback (most recent call last)\r\n<ipython-input-2-ef8b4f2e225d> in <module>()\r\n----> 1 bt = load_table('lolercoaster.biom')\r\n\r\n/Users/yoshikivazquezbaeza/.virtualenvs/qiime-dev/lib/python2.7/site-packages/biom/parse.pyc in load_table(f)\r\n    549     with biom_open(f) as fp:\r\n    550         try:\r\n--> 551             table = parse_biom_table(fp)\r\n    552         except (IndexError, TypeError):\r\n    553             raise TypeError(\"%s does not appear to be a BIOM file!\" % f)\r\n\r\n/Users/yoshikivazquezbaeza/.virtualenvs/qiime-dev/lib/python2.7/site-packages/biom/parse.pyc in parse_biom_table(fp, ids, axis, input_is_dense)\r\n    310         else:\r\n    311             fp.seek(old_pos)\r\n--> 312             t = Table.from_tsv(fp, None, None, lambda x: x)\r\n    313     elif isinstance(fp, list):\r\n    314         try:\r\n\r\n/Users/yoshikivazquezbaeza/.virtualenvs/qiime-dev/lib/python2.7/site-packages/biom/table.pyc in from_tsv(lines, obs_mapping, sample_mapping, process_func, **kwargs)\r\n   3771         \"\"\"\r\n   3772         (sample_ids, obs_ids, data, t_md,\r\n-> 3773             t_md_name) = Table._extract_data_from_tsv(lines, **kwargs)\r\n   3774 \r\n   3775         # if we have it, keep it\r\n\r\n/Users/yoshikivazquezbaeza/.virtualenvs/qiime-dev/lib/python2.7/site-packages/biom/table.pyc in _extract_data_from_tsv(lines, delim, dtype, md_parse)\r\n   3862         else:\r\n   3863             lines.seek(0)\r\n-> 3864             for index in range(0, data_start + 1):\r\n   3865                 line = lines.readline()\r\n   3866 \r\n\r\nUnboundLocalError: local variable 'data_start' referenced before assignment\r\n```\r\n"}}