I am working on importing CSV files with numpy.genfromtxt
.
The data to be imported has a header of column names, and some of those column names contain characters that genfromtxt
considers invalid. Specifically, some of the names contain "#" and " ". The input data cannot be changed as it is generated by other sources that I do not control.
Using names=True
and comments=None
, I am unable to bring in all of the column names that I need.
I've tried overriding numpy.lib.NameValidator.deletechars=None
, but this does not affect the NameValidator class instance that is actually in use.
I understand that deletechars
exists due to the recarray potential to access a field as if it were an attribute. However, I simply must be able to read in column names that include invalid characters, even if the characters are stripped off when read in.
Is there a way to force the NameValidator
to not check for invalid characters, or to modify the characters it checks for? I am unable to modify numpy/lib/_iotools.py as I am not root and it would be bad to modify a shared installation.