import pandas as pd
class ExcelToCsv(object):
def __init__(self, source_path, target_path):
self.source_path = source_path
self.target_path = target_path
def begin(self):
cols = [0, 5, 12, 61] # 需要获取的列数
data = pd.read_excel(self.source_path, usecols=cols)
data.to_csv(self.target_path, index=False, encoding='GBK')
if __name__ == '__main__':
result = ExcelToCsv(r'源文件路径.xlsx',
r'目标文件路径.csv')