1

I have a daily xlsx file output which I take and add to a Master Data xlsx. The data uses a primary key to compare matches, adds and deletes from one day to the next. I currently do this manually. I started messing around a little with utilizing "openpyxl" to do this but haven't gotten very far.

I want to use openpyxl (or another module that would be able to do this task) to load the daily file, copy the data up to the last column and row and then append it to the Master Data xlsx.

It would be nice to eventually take "newest date" primary key compared to "newest date-1" primary key to fill out the "added/match" and "delete/match" columns in the Master Data. First things first though, just getting through the append. I honestly have not gotten far at all. I know the code below is incorrect, however I think it gives an idea of what I am trying to do. The daily output and master data tabs/files have the same number of columns with the same headers in each.

  wb = xl.load_workbook('ReleasedPRsLTLT-Daily.xlsx')
  M = xl.load_workbook('ReleasedPRsLTLT-Master.xlsx')

  sheet = wb.get_sheet_by_name('DailyAppend')
  daily = sheet.range(A1:Max_Row: A1:Max_Column))

  M.append(daily)

Any help is greatly appreciated, thank you!

Jesse
  • 25
  • 1
  • 3
  • 10
  • Related / possible duplicate (old thread): https://stackoverflow.com/questions/20219254/how-to-write-to-an-existing-excel-file-without-overwriting-data-using-pandas – Evan Jan 23 '18 at 17:49
  • 1
    I checked it out it did seem similar, however I only ever see them reference a single tab and file here. I am trying to load two files simultaneously, select the data from file 1,tab1 -->copy/paste data into the Master tab which contains each daily file. So I would need to call up File Name: Daily and File Name: Master – Jesse Jan 23 '18 at 18:02
  • 1
    Do the comparison with something like Pandas and then append what you want need to the file you want to. – Charlie Clark Jan 23 '18 at 18:22
  • I want to append all of the daily file output then do the comparison in the master file only. @CharlieClark can you give an example of the function I would use? – Jesse Jan 23 '18 at 19:00

0 Answers0