1

Fail to Append Data in Existing excel with specific Column using python pandas. How to write clear code to append the results of dataframe in specific column in existing excel?

Code:

import xlsxwriter
wb = xlsxwriter.Workbook(r'G:\alpha.xlsx')
ws = wb.add_worksheet()
data=[df1]
ws.write_column('D2', data)
wb.close()

Existing Excel Alpha.xlsx

 
Col_A   Col_B         Col_C    Col_D   Col_E   Col_F
1       10-10-2022    Amy                      Racing
2       05-10-2022    John                     Music                   
3       04-08-2022    Adam                     Travel
4       07-06-2022    Jenny                    Games

Existing Excel Beta.xlsx

 
Col_A   Col_B     Col_C
1       132150    Section A
2       546546    Section B 
3       556446    Section C
4       123215    Section D

Part 1: Desired Result in Existing Excel Alpha.xlsx

 
Col_A   Col_B         Col_C   Col_D   Col_E    Col_F
1       10-10-2022    Amy             132150   Racing
2       05-10-2022    John            546546   Music 
3       04-08-2022    Adam            556446   Travel
4       07-06-2022    Jenny           123215   Games
Vitalizzare
  • 4,496
  • 7
  • 13
  • 32
aza01
  • 95
  • 1
  • 1
  • 7
  • `ws.write_column('D2', df1[column_name])` – Vitalizzare Aug 11 '23 at 08:46
  • it placed the values in the that column but all other columns data are removed. – aza01 Aug 11 '23 at 09:02
  • [How to append data to existing excel file](https://stackoverflow.com/a/54186803/14909621) – Vitalizzare Aug 11 '23 at 09:13
  • Hi above post is not related, since i need to append data on specific column in existing work book without losing any existing data in other columns. I tried all above possiblities already before posting my question – aza01 Aug 11 '23 at 09:30
  • Append mode is not supported with `xlsxwriter`. Use `openpyxl` instead. See [my new answer here](https://stackoverflow.com/a/76889350/14909621) in the context of your specific question. – Vitalizzare Aug 12 '23 at 12:53

0 Answers0