[英]Reading in Columns from a text file Pandas
I have a large .txt file (many GB) in the the format: 我有一个很大的.txt文件(很多GB),格式为:
|Column1|Column2|Column3|Column4
|"text"|"text"|"text"|"text"
|"text"|"text"|"text"|"text"
I would like to read this data straight into a pandas dataframe. 我想将此数据直接读入pandas数据框。 Is this possible with a pandas command eg 这是可能的熊猫命令,例如
df = pd.read_XXX()
If not with pandas, can someone advise on how to read in a file of this type? 如果不使用熊猫,有人可以建议如何读取此类文件吗? I am not familiar with this format. 我不熟悉这种格式。
You are dealing with a csv
file (comma seperated value). 您正在处理的是csv
文件(逗号分隔值)。
You read this file in pandas with: 您可以通过以下方式在pandas中读取此文件:
df = pd.read_csv('filename.txt', sep='|')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.