Skip a line in genfromtxt

I have the following table:

2M00251602+5422547 7.180 9.000 2.200 #2M00255540+5749320 4.420 5.200 1.600 2M00274401+5330504 4.400 6.800 2.700 2M00331747+6327504 4.540 5.900 0.400 #2M00333033+7054422 4.350 6.700 0.700 2M00350487+5953079 5.310 7.400 1.100 

I would like to skip the lines having hashtags. How to ask genfromtxt to skip lines with hashtag characters?

NOTE. The hashtag does not have to be there. I just need to skip the lines specified by the user.

I know that in IDL under READCOL you can do SKIPSTRING = '#'. Is there something similar in genfromtxt? If not, what program / package can I use to read such a table and skip user-specified lines?

Thanks in advance!

+4
source share
1 answer

Use np.genfromtxt comments='#' .

From the docs:

 comments : str, optional The character used to indicate the start of a comment. All the characters occurring on a line after a comment are discarded 
+5
source

Source: https://habr.com/ru/post/1483951/


All Articles