1

Currently I'm running a live test that uses 3 variables data1, data2 and data 3. The Problem is that whenever I run my python code that it only writes to the first row within the respective columns and overwrites any previous data I had.

import pandas as pd
import xlsxwriter
from openpyxl import load_workbook

def dataholder(data1,data2,data3):
    df = pd.DataFrame({'Col1':[data1],'Col2':[data2],'Col3':[data3]})             
    with pd.ExcelWriter('data_hold.xlsx', engine='openpyxl') as writer:
        df.to_excel(writer,sheet_name='Sheet1')

    writer.save()

Is what I'm trying to accomplish feasible?

kfg456117
  • 21
  • 1

1 Answers1

0

Use startrow=... of to_excel to shift every subsequent update down.

Oleg O
  • 1,005
  • 6
  • 11
  • How would that look like? i tried doing startrow = i and incrementing but it still only used the last update and just shifted the end result down. – kfg456117 Mar 05 '20 at 20:13