高效地读取巨大的 csv 文件?
Reading huge csv files efficiently?
我知道如何使用 pandas 读取 CSV 扩展名的文件。读取大文件时出现内存不足错误。该文件是 380 万行和 640 万列文件。大量人口的档案中主要有基因组数据。
我怎样才能克服这个问题,什么是标准做法以及我如何select为此找到合适的工具。我可以用 pandas 处理这么大的文件吗?还是有其他工具?
您可以使用 Apache Spark 对 csv 文件进行分布式内存处理https://github.com/databricks/spark-csv. Take a look at ADAM's 分布式基因组数据处理方法。
您可以使用 python csv 模块
with open(filename, "r") as csvfile:
datareader = csv.reader(csvfile)
for i in datareader:
#process each line
#You now only hold one row in memory, instead of your thousands of lines
我知道如何使用 pandas 读取 CSV 扩展名的文件。读取大文件时出现内存不足错误。该文件是 380 万行和 640 万列文件。大量人口的档案中主要有基因组数据。
我怎样才能克服这个问题,什么是标准做法以及我如何select为此找到合适的工具。我可以用 pandas 处理这么大的文件吗?还是有其他工具?
您可以使用 Apache Spark 对 csv 文件进行分布式内存处理https://github.com/databricks/spark-csv. Take a look at ADAM's 分布式基因组数据处理方法。
您可以使用 python csv 模块
with open(filename, "r") as csvfile:
datareader = csv.reader(csvfile)
for i in datareader:
#process each line
#You now only hold one row in memory, instead of your thousands of lines