公交数据
1、
#用openpyxl读取excel数据,要事先安装pip install openpyxl
import openpyxl
workbook=openpyxl.load_workbook('gongjiao.xlsx')
sheet=workbook.get_sheet_by_name('Sheet1') #获取第一个sheet
max_row=sheet.max_row #最大行
print(max_row)
max_col=sheet.max_column #最大列
print(max_col)
2、
#space_L空间中有值的填1
from openpyxl import Workbook
wb = Workbook()
# 切换到活动工作表
ws = wb.active
for i in range(1,max_row+1):
for j in range(1,max_col+1):
cell_i_j=sheet.cell(row=i,column=j).value
cell_i_j_1=sheet.cell(row=i,column=j+1).value
if (cell_i_j!=0 and cell_i_j_1!=0) and cell_i_j_1!=None:
# print(cell_i_j,cell_i_j_1)
ws.cell(row=cell_i_j,column=cell_i_j_1).value=1
ws.cell(row=cell_i_j_1,colum