[Python] Python xlwt how DO NOT overwrite the cell?

Discussão em 'Python' iniciado por Stack, Maio 13, 2025.

  1. Stack

    Stack Membro Participativo

    Storing some scraped data with Python Selenium to Excel file, but stuck at the moment of storing the data. Here is a code example which gives me "Attempt to overwrite the cell" exception. I don't want to overwrite the cells, just need to add data from next site page.

    Can you help me? I found similar question here but don't know how to apply it

    i=0
    while i<len(newPagesFile):
    url = "http://example.com"

    browser = webdriver.Firefox()
    browser.get(url)
    time.sleep(5)
    names = browser.find_elements_by_xpath('path1')
    places = browser.find_elements_by_xpath('path2')

    for j, (name, place) in enumerate(zip(names, places)):
    ws.write(i, 0, name.text)
    ws.write(i, 1, place.text)

    i+=1

    Continue reading...

Compartilhe esta Página