访问python中excel工作表的单独行



我希望我的主脚本将excel表读取到单独的行中,如下所述:

image=图像

我只想要python控制台中单独行的详细信息,比如:-

row1 = ['name':row1,'meetid':121121,'neetpass: 12121','endtime':8:15]

有点像

我们使用read_excel读取excel文件
.loc将按行读取您的数据
标头namemeet_idmeet_passmeet_linkstart_timeend_time将不计算
所以您的第一个索引[0]实际上是row1

from pandas import read_excel
data = read_excel("the_data.xlsx")
row1 = data.loc[0]
dictionary = row1.to_dict()
print(dictionary)

这是输出

{'name': 'row1', 'meed_id': 'idgotit', 'meet_pass': 'pass', 'meet_link': 'link', 'start_time': datetime.time(21, 43), 'end_time': datetime.time(10, 15)}

你可以试试pandas:

import pandas as pd
df = pd.read_excel('temp.xlsx')
print(df.to_dict('index'))

现在所有的行都在字典里了。

输出:

{0: {'a': 1, 'b': 2, 'c': 3}, 1: {'a': 4, 'b': 5, 'c': 6}}

然后可以使用行号作为关键字来访问每一行。

最新更新