Python: How to read huge text file into memory

前端 未结 6 1056
自闭症患者
自闭症患者 2020-11-29 21:36

I\'m using Python 2.6 on a Mac Mini with 1GB RAM. I want to read in a huge text file

$ ls -l links.csv; file links.csv; tail links.csv 
-rw-r--r--  1 user  u         


        
6条回答
  •  时光说笑
    2020-11-29 22:11

    I created a module for this use case using external merge sort: https://bitbucket.org/richardpenman/csvsort

    >>> from csvsort import csvsort
    >>> csvsort('links.csv', columns=[1], has_header=False)
    

提交回复
热议问题