Extract specific text lines?

前端 未结 10 1081
庸人自扰
庸人自扰 2021-02-03 15:09

I have a large several hudred thousand lines text file. I have to extract 30,000 specific lines that are all in the text file in random spots. This is the program I have to extr

10条回答
  •  日久生厌
    2021-02-03 15:40

    The best bet to speed it up would be if the specific string S0414 always appears at the same character position, so instead of having to make several failed comparisons per line (you said they start with different names) it could just do one and done.

    e.g. if you're file has lines like

    GLY S0414 GCT
    ASP S0435 AGG
    LEU S0432 CCT
    

    do an if line[4:9] == 'S0414': small.write(line).

提交回复
热议问题