How do quickly search through a .csv file in Python

后端 未结 6 984
别跟我提以往
别跟我提以往 2020-12-18 09:10

I\'m reading a 6 million entry .csv file with Python, and I want to be able to search through this file for a particular entry.

Are there any tricks to search the en

6条回答
  •  孤城傲影
    2020-12-18 10:08

    You can't go directly to a specific line in the file because lines are variable-length, so the only way to know when line #n starts is to search for the first n newlines. And it's not enough to just look for '\n' characters because CSV allows newlines in table cells, so you really do have to parse the file anyway.

提交回复
热议问题