Skip to content

Improve io.ascii.read guess when inputting file objects - #3132

Merged
taldcroft merged 2 commits into
astropy:masterfrom
taldcroft:io-ascii-guess-fileobj
Nov 24, 2014
Merged

taldcroft merged 2 commits into
astropy:masterfrom
taldcroft:io-ascii-guess-fileobj

Conversation

@taldcroft

Copy link
Copy Markdown
Member

In Python 3 (only) the following fails:

from astropy.io import ascii
t = ascii.read(open('astropy/io/ascii/tests/t/ipac.dat.bz2', 'rb'))

This is closely related to #3013 and issues raised in #3109. This PR puts in a fix in the ui._guess() which reads the entire file into memory if a file object is supplied. This fixes the Python 3 problem and should be more efficient in Python 2 because the file is not re-read during the guess process.

@hamogu

hamogu commented Nov 24, 2014

Copy link
Copy Markdown
Member

Looks like a good fix for the specific situation of reading ASCII tables to me.

@astrofrog

Copy link
Copy Markdown
Member

This seems sensible to me, and for anyone who cares about very big tables, they shouldn't be using guessing anyway.

taldcroft added a commit that referenced this pull request Nov 24, 2014
Improve io.ascii.read guess when inputting file objects
@taldcroft
taldcroft merged commit 1fc5831 into astropy:master Nov 24, 2014
@taldcroft
taldcroft deleted the io-ascii-guess-fileobj branch November 24, 2014 15:36
@embray

embray commented Nov 24, 2014

Copy link
Copy Markdown
Member

This also seems to be closely related to #2001, though it didn't fix that issue.

taldcroft added a commit that referenced this pull request Dec 31, 2014
Improve io.ascii.read guess when inputting file objects
Conflicts:
	astropy/io/ascii/tests/test_read.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants