{"action":"created","issue":{"url":"https://api.github.com/repos/pydata/pandas/issues/13398","repository_url":"https://api.github.com/repos/pydata/pandas","labels_url":"https://api.github.com/repos/pydata/pandas/issues/13398/labels{/name}","comments_url":"https://api.github.com/repos/pydata/pandas/issues/13398/comments","events_url":"https://api.github.com/repos/pydata/pandas/issues/13398/events","html_url":"https://github.com/pydata/pandas/issues/13398","id":159161298,"number":13398,"title":"TemporaryFile as input to read_table raises TypeError: '_TemporaryFileWrapper' object is not an iterator","user":{"login":"mbrucher","id":321752,"avatar_url":"https://avatars.githubusercontent.com/u/321752?v=3","gravatar_id":"","url":"https://api.github.com/users/mbrucher","html_url":"https://github.com/mbrucher","followers_url":"https://api.github.com/users/mbrucher/followers","following_url":"https://api.github.com/users/mbrucher/following{/other_user}","gists_url":"https://api.github.com/users/mbrucher/gists{/gist_id}","starred_url":"https://api.github.com/users/mbrucher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbrucher/subscriptions","organizations_url":"https://api.github.com/users/mbrucher/orgs","repos_url":"https://api.github.com/users/mbrucher/repos","events_url":"https://api.github.com/users/mbrucher/events{/privacy}","received_events_url":"https://api.github.com/users/mbrucher/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pydata/pandas/labels/Bug","name":"Bug","color":"e10c02"},{"url":"https://api.github.com/repos/pydata/pandas/labels/CSV","name":"CSV","color":"5319e7"},{"url":"https://api.github.com/repos/pydata/pandas/labels/Difficulty%20Novice","name":"Difficulty Novice","color":"fbca04"},{"url":"https://api.github.com/repos/pydata/pandas/labels/Effort%20Low","name":"Effort Low","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/pydata/pandas/milestones/32","html_url":"https://github.com/pydata/pandas/milestones/Next%20Major%20Release","labels_url":"https://api.github.com/repos/pydata/pandas/milestones/32/labels","id":933188,"number":32,"title":"Next Major Release","description":"after 0.18.0 of course","creator":{"login":"jreback","id":953992,"avatar_url":"https://avatars.githubusercontent.com/u/953992?v=3","gravatar_id":"","url":"https://api.github.com/users/jreback","html_url":"https://github.com/jreback","followers_url":"https://api.github.com/users/jreback/followers","following_url":"https://api.github.com/users/jreback/following{/other_user}","gists_url":"https://api.github.com/users/jreback/gists{/gist_id}","starred_url":"https://api.github.com/users/jreback/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jreback/subscriptions","organizations_url":"https://api.github.com/users/jreback/orgs","repos_url":"https://api.github.com/users/jreback/repos","events_url":"https://api.github.com/users/jreback/events{/privacy}","received_events_url":"https://api.github.com/users/jreback/received_events","type":"User","site_admin":false},"open_issues":970,"closed_issues":145,"state":"open","created_at":"2015-01-13T10:53:19Z","updated_at":"2016-06-17T22:07:01Z","due_on":"2016-08-31T04:00:00Z","closed_at":null},"comments":16,"created_at":"2016-06-08T13:18:20Z","updated_at":"2016-06-18T14:33:11Z","closed_at":null,"body":"Although the requirement in the doc says that the input can be a file like object, it doesn't work with objects from tempfile. On Windows, they can't be reopened, so I need to pass the object itself.\r\n\r\n#### Code Sample, a copy-pastable example if possible\r\n\r\n```\r\nimport pandas as pd\r\nfrom tempfile import TemporaryFile\r\nnew_file = TemporaryFile(\"w+\")\r\ndataframe = pd.read_table(new_file, skiprows=3, header=None, sep=r\"\\s*\")\r\n```\r\n\r\n#### Expected Output\r\nNot an exception!\r\n\r\n#### output of ``pd.show_versions()``\r\nINSTALLED VERSIONS\r\n------------------\r\ncommit: None\r\npython: 3.5.1.final.0\r\npython-bits: 64\r\n\r\npandas: 0.18.0\r\n"},"comment":{"url":"https://api.github.com/repos/pydata/pandas/issues/comments/226945529","html_url":"https://github.com/pydata/pandas/issues/13398#issuecomment-226945529","issue_url":"https://api.github.com/repos/pydata/pandas/issues/13398","id":226945529,"user":{"login":"jreback","id":953992,"avatar_url":"https://avatars.githubusercontent.com/u/953992?v=3","gravatar_id":"","url":"https://api.github.com/users/jreback","html_url":"https://github.com/jreback","followers_url":"https://api.github.com/users/jreback/followers","following_url":"https://api.github.com/users/jreback/following{/other_user}","gists_url":"https://api.github.com/users/jreback/gists{/gist_id}","starred_url":"https://api.github.com/users/jreback/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jreback/subscriptions","organizations_url":"https://api.github.com/users/jreback/orgs","repos_url":"https://api.github.com/users/jreback/repos","events_url":"https://api.github.com/users/jreback/events{/privacy}","received_events_url":"https://api.github.com/users/jreback/received_events","type":"User","site_admin":false},"created_at":"2016-06-18T14:33:11Z","updated_at":"2016-06-18T14:33:11Z","body":"```\r\nIn [2]: import pandas as pd\r\n\r\nIn [3]: pd.__version__\r\nOut[3]: '0.18.1+139.ge24ab24'\r\n\r\nIn [4]: import pandas as pd\r\n\r\nIn [5]: from tempfile import TemporaryFile\r\n\r\nIn [6]: new_file = TemporaryFile(\"w+\")\r\n\r\nIn [7]: dataframe = pd.read_table(new_file, skiprows=3, header=None, sep=r\"\\s*\")\r\nC:\\Miniconda2\\envs\\pandas3.5\\Scripts\\ipython-script.py:1: ParserWarning: Falling back to the 'python' engine because the 'c' engine does not\r\n support regex separators (separators > 1 char and different from '\\s+' are interpreted as regex); you can avoid this warning by specifying\r\nengine='python'.\r\n  if __name__ == '__main__':\r\n---------------------------------------------------------------------------\r\nTypeError                                 Traceback (most recent call last)\r\n<ipython-input-7-43d01852f446> in <module>()\r\n----> 1 dataframe = pd.read_table(new_file, skiprows=3, header=None, sep=r\"\\s*\")\r\n\r\nC:\\Users\\conda\\Documents\\pandas3.5\\pandas\\io\\parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, s\r\nqueeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_va\r\nlues, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, itera\r\ntor, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, escapechar, comment, encoding, dialect, tupleize_cols,\r\nerror_bad_lines, warn_bad_lines, skip_footer, doublequote, delim_whitespace, as_recarray, compact_ints, use_unsigned, low_memory, buffer_lin\r\nes, memory_map, float_precision)\r\n    627                     skip_blank_lines=skip_blank_lines)\r\n    628\r\n--> 629         return _read(filepath_or_buffer, kwds)\r\n    630\r\n    631     parser_f.__name__ = name\r\n\r\nC:\\Users\\conda\\Documents\\pandas3.5\\pandas\\io\\parsers.py in _read(filepath_or_buffer, kwds)\r\n    380\r\n    381     # Create the parser.\r\n--> 382     parser = TextFileReader(filepath_or_buffer, **kwds)\r\n    383\r\n    384     if (nrows is not None) and (chunksize is not None):\r\n\r\nC:\\Users\\conda\\Documents\\pandas3.5\\pandas\\io\\parsers.py in __init__(self, f, engine, **kwds)\r\n    710             self.options['has_index_names'] = kwds['has_index_names']\r\n    711\r\n--> 712         self._make_engine(self.engine)\r\n    713\r\n    714     def close(self):\r\n\r\nC:\\Users\\conda\\Documents\\pandas3.5\\pandas\\io\\parsers.py in _make_engine(self, engine)\r\n    894             elif engine == 'python-fwf':\r\n    895                 klass = FixedWidthFieldParser\r\n--> 896             self._engine = klass(self.f, **self.options)\r\n    897\r\n    898     def _failover_to_python(self):\r\n\r\nC:\\Users\\conda\\Documents\\pandas3.5\\pandas\\io\\parsers.py in __init__(self, f, **kwds)\r\n   1742         # infer column indices from self.usecols if is is specified.\r\n   1743         self._col_indices = None\r\n-> 1744         self.columns, self.num_original_columns = self._infer_columns()\r\n   1745\r\n   1746         # Now self.columns has the set of columns that we will process.\r\n\r\nC:\\Users\\conda\\Documents\\pandas3.5\\pandas\\io\\parsers.py in _infer_columns(self)\r\n   2068         else:\r\n   2069             try:\r\n-> 2070                 line = self._buffered_line()\r\n   2071\r\n   2072             except StopIteration:\r\n\r\nC:\\Users\\conda\\Documents\\pandas3.5\\pandas\\io\\parsers.py in _buffered_line(self)\r\n   2136             return self.buf[0]\r\n   2137         else:\r\n-> 2138             return self._next_line()\r\n   2139\r\n   2140     def _empty(self, line):\r\n\r\nC:\\Users\\conda\\Documents\\pandas3.5\\pandas\\io\\parsers.py in _next_line(self)\r\n   2164             while self.pos in self.skiprows:\r\n   2165                 self.pos += 1\r\n-> 2166                 next(self.data)\r\n   2167\r\n   2168             while True:\r\n\r\nC:\\Users\\conda\\Documents\\pandas3.5\\pandas\\io\\parsers.py in _read()\r\n   1869         else:\r\n   1870             def _read():\r\n-> 1871                 line = next(f)\r\n   1872                 pat = re.compile(sep)\r\n   1873                 yield pat.split(line.strip())\r\n\r\nTypeError: '_TemporaryFileWrapper' object is not an iterator\r\n```"}}
{"actor":{"display_login":"jreback"}}