genfromtxt with names=True doesn't skip comments
See original GitHub issueIf numpy.genfromtxt() is called with names=True
, as is the case with numpy.recfromcsv(), then the comment lines are ignored. This is due to the following code block:
# Keep on until we find the first valid values
first_values = None
try:
while not first_values:
first_line = next(fhd)
if names is True:
if comments in first_line:
first_line = asbytes('').join(first_line.split(comments)[1:])
first_values = split_line(first_line)
Is this the intended behavior? It seems like comments should be read and ignored regardless if names is True
.
Issue Analytics
- State:
- Created 10 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Numpy genfromtxt doesn't seem to work when names=True for ...
With my_data = genfromtxt('DlRefinedRatings.csv', delimiter=',' , dtype=int, max_rows=100). I got a (100,4) int array. With names=True it ...
Read more >Importing data with genfromtxt — NumPy v1.25.dev0 Manual
There is one notable exception to this behavior: if the optional argument names=True , the first commented line will be examined for names....
Read more >Importing data with genfromtxt — NumPy v1.9 Manual
There is one notable exception to this behavior: if the optional argument names=True, the first commented line will be examined for names. Skipping...
Read more >NumPy Input and Output: genfromtxt() function - w3resource
Data type of the resulting array. If None, the dtypes will be determined by the contents of each column, individually. dtype, Optional. comments...
Read more >Reading Text Tables with Python - Pen and Pants
That can be useful if you want to skip a text column. ... If you set names=True numpy.genfromtxt will take the column names...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Not yet, it’s on my TODO list - I actually have a rough draft for SciPy based on our recent triage effort there. So far all your comments have been spot on, so please imagine there’s a policy in line with what you did over the past couple of days:)
No commitments of course, we’re all volunteers (well, almost all)! Your efforts are much appreciated:)
thanks @bsipocz. triaging these old issues is quite useful. I’ll send you an invite for the triage team, so you can add labels, and close issues yourself if something is clearly fixed or invalid.