thouis / numpy-trac-migration

numpy Trac to github issues migration
2 stars 3 forks source link

npyio.py: Make .squeeze() an option for genfromtxt() (Trac #2172) #5962

Open numpy-gitbot opened 11 years ago

numpy-gitbot commented 11 years ago

Original ticket http://projects.scipy.org/numpy/ticket/2172 on 2012-06-19 by trac user lmeyn, assigned to unknown.

I'm trying to read several data files with column headers using numpy.genfromtxt. The issue is that some of the data files only have one row of data and squeeze operation used in genfromtxt returns an object with no rows (shape = () ). I would suggest adding an argument, squeeze=True, and the replace the last three lines

if unpack:
    return output.squeeze().T
return output.squeeze()

with:

if squeeze:
    output = output.squeeze()
if unpack:
    return output.T
return output

This would keep the current behavior if the squeeze argument isn't specified, yet allow the squeeze operation to be avoided if desired.

numpy-gitbot commented 11 years ago

Title changed from Make .squeeze() an option for genfrontxt() to Make .squeeze() an option for genfromtxt() by trac user lmeyn on 2012-06-19

numpy-gitbot commented 11 years ago

Title changed from Make .squeeze() an option for genfromtxt() to npyio.py: Make .squeeze() an option for genfromtxt() by trac user lmeyn on 2012-06-19