在python中使用文本文件提取列
我正在尝试使用文本文件从包含数千行的excel文件中提取特定列,然后创建一个新工作簿来记录我的新结果 文本文件包含所需的列标题 我希望将txt文件和电子表格读入dict,然后比较两个dict(如果结果匹配)并添加到新的workboook中 这就是我到目前为止所做的:在python中使用文本文件提取列,python,excel,dictionary,text-files,Python,Excel,Dictionary,Text Files,我正在尝试使用文本文件从包含数千行的excel文件中提取特定列,然后创建一个新工作簿来记录我的新结果 文本文件包含所需的列标题 我希望将txt文件和电子表格读入dict,然后比较两个dict(如果结果匹配)并添加到新的workboook中 这就是我到目前为止所做的: def read_text_file(): # read txt file C = open("config_file.txt", "r") text_file = C.readlines() d =
def read_text_file():
# read txt file
C = open("config_file.txt", "r")
text_file = C.readlines()
d = []
for i in text_file:
d.append(i)
print (d)
C.close()
def get_spreadsheet():
df = p.DataFrame()
inputFiles = p.read_excel('Report.xlsx', sheetname='Sheet1')
for i in inputFiles:
print df
get_spreadsheet()
您是否查看了阅读文本文件的
pd.read_csv
和pd.read_fwf
?是否查看了阅读文本文件的pd.read_csv
和pd.read_fwf
?