Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. from xlrd import open_workbook
  2. import pandas as pd
  3. from xlrd import open_workbook
  4.  
  5. # filter out all sheets that are not Pro (aka: models)
  6. with open('t0.xlsx', 'rb') as f:
  7.     book = open_workbook('t0.xlsx')
  8. sheets = [sheet for sheet in book.sheet_names() if sheet.startswith('Pro')]
  9. mapping = {}
  10. for number, sheet in enumerate(sheets):
  11.     mapping[number+1] = sheet
  12. print(mapping)
  13.  
  14. # remove all 0 values from models
  15. with open('t0.xlsx', 'rb') as f:
  16.     df = pd.read_excel(f, sheet_name='EM1')
  17.     df.loc[df[no_y != 0]]
  18.  
  19. # now doit
  20. with open('t0.xlsx',  'rb'):
  21.     wb = openpyxl.load_workbook('t0.xlsx')
  22.     print(wb.sheetnames)
  23.     sheet = wb['Procédure et Relevé_AVEC BONI']
  24.     sheet['U9'] = 99999
  25.    
  26.  
  27.     wb.save('t7.xlsx')
  28.     wb.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement