简体   繁体   English

使用 pandas 逐块读取 txt 文件

[英]Read txt file by chunks with pandas

Pandas gives you the feature of reading CSV and SQL queries by chunks, how could I do that with.txt files? Pandas 为您提供了按块读取 CSV 和 SQL 查询的功能,我怎么能用 .txt 文件做到这一点?

If the.txt file follows some pattern with a specific separator, you can use pandas read_csv.如果 .txt 文件遵循带有特定分隔符的某种模式,则可以使用 pandas read_csv。

Or I will recommend you to read the file with open() function, do some parsing, and create a dataframe with the result或者我会建议你用 open() function 读取文件,做一些解析,然后用结果创建一个 dataframe

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM