import xlrd
from xlrd import xldate_as_tuple
import json
import requests
import datetime
import openpyxl
import os
import time
from bs4 import BeautifulSoup
import requests
import random
#第一步Execl中数据的获取
class ExcelData():
def __init__(self, data_path, sheetname):
self.data_path = data_path
self.sheetname = sheetname
self.data = xlrd.open_workbook(self.data_path)
self.table = self.data.sheet_by_name(self.sheetname)
self.keys = self.table.row_values(0)
self.rowNum = self.table.nrows
self.colNum = self.table.ncols
def readExcel(self):
datas = []
for i in range(1, self.rowNum):
sheet_data = {}
for j in range(self.colNum):
c_type = self.table.cell(i,j).ctype
c_cell = self.table.cell_value(i, j)
if c_type == 2 and c_cell % 1 == 0:
c_cell = int(c_cell)
elif c_type == 3:
date = datetime.datetime(*xldate_as_tuple(c_cell,0))
c_cell = date.strftime('%Y/%d/%m %H:%M:%S')
elif c_type == 4:
c_cell = True if c_cell == 1 else False
sheet_data[self.keys[j]] =