The code is as follows
import os import pandas as pd df =
pd.DataFrame(columns=[' Serial number ',' Event name ',' Name of our account ',' Account name of the other party ',' flow time ',' operator ',' a turnover ',' Water mark ',' Sector code '])
l = [] num = [] def search(path): parents = os.listdir(path) sum = 0 for parent
in parents: # Returns the names of all files and folders in the specified path , And stored in a list child = os.path.join(path,parent) if
os.path.isdir(child): # Multiple paths will be combined search(child) elif os.path.isfile(child): #
If it's a catalog , Then continue to traverse the files in the subdirectory if os.path.splitext(child)[1] == '.xls': #
Split file name and file extension , And the extension is 'xls' d = pd.read_excel(child) for i in range(len(d)):
num.append(os.path.split(child)[1][0:9]) l.append(d)
#search(r'C:\\Users\aming\\Desktop\\ Behavior analysis of College Students \\ Logistics data \\ Student data _LHJ_YJ')
search(r'C:\\Users\aming\\Desktop\\ Behavior analysis of College Students \\ Logistics data \\ Student data _LHJ_YJ\1250111\2012-8-1_2014-7-15')
df = pd.concat(l) da = pd.Series(num) df[' Student number '] = da df =
df.drop(columns=[' Serial number ',' Sector code ',' Serial number ',' operator ',' Water mark '],axis=1) # Delete entire column as NAN Column of
df.to_excel('rone.xlsx',index=False) # Save as result file

©2020 ioDraw All rights reserved
django Do not close CSRF middleware , Custom through CSRF Tested post request Understanding neural network machine translation in three minutes error: (-215:Assertion failed) Solution ETL tool kettle And datax Comparison test cases Oracle to Oracle Tiktok The matrix - Code rain ( Free delivery ) Interview questions : Handwritten list ( Include reverse linked list )-bash The Trojan horse , Have you ever met one ? Implementation and challenge of metadata service in data Lake PHP call shell command Notes on core principles of reverse engineering ( One )——Hello World-1