PDA

View Full Version : Python scripts for combining excel files



GEZA
2018-12-04, 04:24 PM
I use this scripts to combined OSS stats from multiple Huawei PRS.

Hope it helps.

written in python 3


import pandas as pdimport os
import datetime


rootDir = os.getcwd()
filelist = []
excellist = []


today = datetime.date.today()
delta = datetime.timedelta(days=-1)
yesterday = today + delta


startDate = yesterday.strftime('%Y%m%d')




#get all xlsx files
for filename in os.listdir(rootDir):
if os.path.splitext(filename)[1] == '.xlsx':
filelist.append(filename)


#file name of combined file
filename_combined = startDate + 'Huawei All.xlsx'


writer = pd.ExcelWriter(filename_combined)


#read info to list
for excelfile in filelist:
excellist.append(pd.read_excel(excelfile))


#write combined info to excel file
newdf = pd.concat(excellist,sort=False)
newdf.to_excel(writer,index=False)


#save excel file
writer.save()

BlackX
2018-12-05, 10:45 PM
Or you can try "Power query" which is a EXCEL plug-in published by Microsoft

it is free and it has lots of training material on internet

carver
2018-12-06, 04:45 AM
the beauty of scripts,
in that they do all your work at night,
often on Ubuntu Server,
also add a couple of lines to the weekly report ))

mashi123
2018-12-06, 08:48 PM
Or you can try "Power query" which is a EXCEL plug-in published by Microsoft

it is free and it has lots of training material on internet
agree totally i user power query since two years now , its really powerfull , i even stopped using PRS

jkpllan3
2018-12-07, 10:20 PM
Hi,

I'm very fluent in python, but I prefer to use Power BI to do this kind of work. My reasons:
1. Very intuitive
2. Anyway after you combine the files I would like to make some chart
3. Visualizations a very beautiful (not just the boring Excel charts we have like 20 years seeming)
3. Power BI charts are dynamic, that means you can create for example a map to show sites by clicking a table
4. It is also FREE

Boraa
2018-12-08, 04:16 PM
@jkpllan3 (http://www.finetopix.com/member.php/15216-jkpllan3)
could share some video or tutorial to do it with Power BI , it will be very helpful
I mean how you are Power BI in RF

mashi123
2018-12-12, 02:54 PM
@jkpllan3 (http://www.finetopix.com/member.php/15216-jkpllan3)
could share some video or tutorial to do it with Power BI , it will be very helpful
I mean how you are Power BI in RF
https://www.edx.org/course/analyzing-visualizing-data-power-bi-microsoft-dat207x-0