Python Random Access File

前端 未结 7 2131
借酒劲吻你
借酒劲吻你 2020-12-01 16:10

Is there a Python file type for accessing random lines without traversing the whole file? I need to search within a large file, reading the whole thing into memory wouldn\'t

7条回答
  •  醉话见心
    2020-12-01 16:55

    Has fixed-length records? If so, yes, you can implement a binary search algorithm using seeking.

    Otherwise, load your file into an SQLlite database. Query that.

提交回复
热议问题