我有一个非常无组织的数据集,位于文本文件中,说file.txt
样本看起来像这样
TYPE Invoice C AC DATE TIME Total Invoice Qty1 ITEMVG By Total 3,000.00
Piece Item
5696 01/03/2018 09:21 32,501.35 1 Golden Plate ÞÔÞæÇä ÈÞÑ 6,517.52
1 áÈä ÑæÇÈí ÊÚäÇíá 2 ßÛ 4,261.45
1 Magic chef pop corn 907g 3,509.43
1 áÈäÉ ÊÚäÇíá ÔÝÇÝÉ 1 ßíáæ 9,525.60
1 KHOURY UHT 1 L 2,506.74
1 ÎÈÒ ÔãÓíä ÕÛíÑ 1,002.69
2 Almera 200Tiss 2,506.74
1.55 VG Potato 1,550.17
0.41 VG Eggplant 619.67
1 Delivery Charge 501.35
5697 01/03/2018 09:31 15,751.35 0.5 Halloum 1K. 4,476.03
0.59 Cheese double Cream 3,253.75
3 ãæáÇä ÏæÑ ÎÈÒ æÓØ 32 3,760.11
3 ãæáÇä ÏæÑ ÎÈÒ æÓØ 32 3,760.11
1 Delivery Charge 501.35
我想使用多索引将其导入数据框pandas。有人可以帮我这个吗?
实际上它无法将其作为txt文件读取
# Obtain the Unorganized data from txt
file1=open('file.txt','r')
UnOrgan=file1.read()
答案 0 :(得分:0)
您应该可以使用read_table
阅读它。
import pandas as pd
df = pd.read_table(<your file>, sep="\t", headers=[rows with column info])
我猜测分隔符是一个标签。