读取csv和excel
import pandas as pd #没安装pandas的可以使用 pip install pandas 安装
data = pd.read_csv('./data.csv') #读取csv
lib = pd.read_excel('./library.xls') #读取excel
print(data)
# 输出csv数据如下:
时间 馆代码 UID 条码号 馆藏地代码
0 2023-12-07 14:56:30 [TSG] [E0041D100725F455] [00015069] [001]
1 2023-12-07 14:56:31 [TSG] [E0041D100725F461] [00015073] [001]
2 2023-12-07 14:56:31 [TSG] [E0041D100725F453] [00015071] [001]
3 2023-12-07 14:56:31 [TSG] [E0041D100725F454] [00015070] [001]
4 2023-12-07 14:56:31 [TSG] [E0041D100725F457] [00015067] [001]
... ... ... ... ... ...
1034 2023-12-07 15:35:54 [TSG] [E0041D1004653C6D] [00016278] [001]
1035 2023-12-07 15:35:55 [TSG] [E0041D1004653C6E] [00016277] [001]
1036 2023-12-07 15:35:55 [TSG] [E0041D1004653C6F] [00016276] [001]
1037 2023-12-07 15:35:56 [TSG] [E0041D1004653C70] [00016275] [001]
1038 2023-12-07 15:35:57 [TSG] [E0041D1004653C71] [00016274] [001]
访问数据
for n in data['条码号']:
print(n)
print(data['条码号'][0]) #直接索引访问就行。csv和excel一样
标签:12,07,光速,TSG,001,2023,csv,pandas,入门
From: https://www.cnblogs.com/mariocanfly/p/17887050.html