Question

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 that have a hashtag. How do ask genfromtxt to skip rows that have hashtag symbols?

NOTE: The hashtag does not need to be there. I just need to skip a user-specified rows.

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

Thanks in advance!

Was it helpful?

Solution

Use np.genfromtxt's comments='#' parameter.

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top