Guest User

Untitled

a guest
Nov 18th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. import docx
  2. from bcompiler.utils import project_data_from_master
  3.  
  4. def get_project_names(master_sheet):
  5. data = project_data_from_master(master_sheet)
  6. data = list(enumerate(data, start=1))
  7. output_list = []
  8. for x in data:
  9. output_list.append(x[1])
  10. return output_list
  11.  
  12. def get_dictionary_data(project_title, master_sheet, cell_keys):
  13. data = project_data_from_master(master_sheet)
  14. project_data = data[project_title]
  15. output_list = []
  16. for item in project_data.items():
  17. if item[0] in cell_keys:
  18. output_list.append(item)
  19. return output_list
  20.  
  21. def run(master_sheet):
  22. doc = docx.Document()
  23. summary_output_list = get_project_names(master_sheet)
  24. cells_we_want_to_capture = ['Brief project description (GMPP - brief descripton)',
  25. 'Project Scope']
  26. final_output_list = []
  27. for x in summary_output_list:
  28. final_output_list.append(x)
  29. final_output_list.append(get_dictionary_data(x, master_sheet, cells_we_want_to_capture))
  30. return final_output_list
  31. for x in final_output_list:
  32. doc.add_paragraph(x)
  33. doc.add_paragraph(x[0])
  34. doc.save('C:\\Users\\Standalone\\Documents\\bcompiler\\test.docx')
  35.  
  36. run('C:\\Users\\Standalone\\Documents\\bcompiler\\target_master.xlsx')
Add Comment
Please, Sign In to add comment