thouis / numpy-trac-migration

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

Allow autostrip keyword in genfromtxt (migrated from Trac #1238) #2791

Closed thouis closed 11 years ago

thouis commented 11 years ago

Original ticket http://projects.scipy.org/numpy/ticket/1238 Reported 2009-09-24 by atmention:jseabold, assigned to unknown.

This allows the user to specify whether the whitespace should be stripped from strings in genfromtxt. It does not change the default behavior.

This is how it was handled.

from StringIO import StringIO import numpy as np s = StringIO("1/4/2003 ,1.3,abcde") data = np.genfromtxt(s, dtype=None, delimiter=',') data array(('1/4/2003 ', 1.3, 'abcde'), dtype=[('f0', '|S10'), ('f1', '<f8'), ('f2', '|S5')]) Now you can do s.seek(0) data = np.genfromtxt(s, dtype=None, delimiter=',', autostrip=True) data array(('1/4/2003', 1.3, 'abcde'), dtype=[('f0', '|S8'), ('f1', '<f8'), ('f2', '|S5')]) Diff file attached.

thouis commented 11 years ago

Attachment in Trac by atmention:jseabold, 2009-09-24: diffpatch.txt

thouis commented 11 years ago

Comment in Trac by atmention:pierregm, 2009-10-09

Can you try r7508 and report back ? Thx!

thouis commented 11 years ago

Comment in Trac by atmention:jseabold, 2009-10-09

This looks good to me.

thouis commented 11 years ago

Comment in Trac by atmention:pierregm, 2009-10-09

OK then, I'm closing the ticket