Trying to remove top row from excel spreadsheet using Python -
this first question here if don't follow perfect etiquette please forgive me. have been searching answer 6 hours figured time ask. i'm new python, , i'm trying automate data entry selenium. i'm doing well, stuck @ part pull data excel. data pulling isn't problem, telling excel delete top row, or move onto next, is. here sample of script:
import pandas pd pandas import excelwriter import numpy np xl = pd.excelfile('c:\\users\\steph_000\\desktop\\students2.xlsx') xl wr = pd.excelwriter('c:\\users\\steph_000\\desktop\\students2.xlsx') xl.sheet_names ['sheet1'] df = xl.parse('sheet1') #this reads sheet dataframe df cp = pd.read_excel('c:\\users\\steph_000\\desktop\\students2.xlsx') idnum = cp[:1] #this pulls first row variable print(idnum) #this prints search bar student chart = cp[1:] #this pulls first row variable print(chart) df.to_excel(wr, 'sheet1') wr.save() #this supposed overwrite it, saves blank
no matter do, can't move rows, or that. i'm struggling , frustrated. i'll use different python wrapper pandas if have to, i've tried openpyxl, xlrd, , xlwr no avail! pulling hair out, in advance!
look @ example below:
- missing engine='xlsxwriter'
- missing sheet_name='sheet1
look @ this:
import pandas pd #create pandas dataframe data. df = pd.dataframe({'data': [10, 20, 30, 20, 15, 30, 45]}) # create pandas excel writer using xlsxwriter engine. writer = pd.excelwriter('pandas_simple.xlsx', engine='xlsxwriter') # convert dataframe xlsxwriter excel object. df.to_excel(writer, sheet_name='sheet1') # close pandas excel writer , output excel file. writer.save()
Comments
Post a Comment