Python-Pandas Library implementation EXCEL Data is split into different tables , And batch naming , By the way, review the display of the text progress bar

<>Python-Pandas Library implementation EXCEL Data is split into different tables

Why : Persisting in laziness is the first productive force , Colleagues said that there are about 100000 lines of data , You need to split into different tables based on the values in a column , At the same time, the file name should be changed to the corresponding region + residential quarters + code + name , Easy email .

<>Pandas library +os Library implementation

use os Library to create a folder ,Pandas Achieve split , By the way, review the display of the text progress bar :

* os library ,os.path.exists(path) Judge whether there is a corresponding path ;os.mkdir(path) establish
* Pandas library : After de duplicating the columns to be split , Select the corresponding number of rows , Through the index to achieve the need to select the region , residential quarters , code , Name , last to_excel Method implementation
* Text progress bar : adopt count Real time statistics have been generated EXCEL number , Through and len( Split column after de duplication ) Compare and realize split progress display .
<> Code section
#-*- coding = utf-8 -*- #@Time:2020/4/24 19:02 #@Author:OULA-WANG
#@File:SplitExcel.PY import pandas as pd import os data = pd.read_excel(
'./data.xlsx')# Read data data_list = list(data[' name '].drop_duplicates())# De reprocessing longth =
len(data_list)# Calculate the total quantity path = './SplitExcel' if not os.path.exists(path):
# Does this folder exist in the current folder os.mkdir(path)# Create this folder count = 0 for item in data_list:
data_select= data[data[' name ']==item]# elect item Corresponding line Bigzone = data_select.iat[0,0]
# Values that need to participate in file naming Smallzone = data_select.iat[0,1] service_code = data_select.iat[0,2]
Smallzone,service_code,item),index=False)# Generated according to the corresponding value EXCEL file count += 1 print(
'\rEXCEL There are two types in the table {} Names , Splitting page {} Home data , Split progress :{:.2%}'.format(longth, count, count /
longth),end="") print('\n{} All names have been split , Please go SplitExcel Folder to view the split file data .'.format(

# Life is short , I use it Python#, I've been studying for just two months , I don't feel like I'm getting started .Python It really works , keep trying , Strive to be an amateur programmer ..

©2020 ioDraw All rights reserved
0.96OLED display -4 Line SPI explain C++11 of std::function,std::bind,std::placeholdersJavaScript study ( Function declaration and parameters )QTabWidget Style sheet settings The project passed idea Package and publish to tomcat The server postman Interface test get timestamp and MD5 encryption react Background management configuration route and sidebar :python Simple game code -10 Minutes Python Write a snake game , simple You know? Python What does the foundation include ? Learn something ?10 individual Python Introduction to crawler