1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Python gspread create sheet if not exist

Discussão em 'Python' iniciado por Stack, Setembro 16, 2024.

  1. Stack

    Stack Membro Participativo

    I am trying to create a new sheet called "BOT: output". However, if I run the code once it works fine, but when I run the code again and that sheet exist it gives me an error. I tried to create an if condition to see if the sheet exist just identify it as wks2, but this will give an error if the sheet itsn't there in the first place.

    try:
    wks2 = mySheet.worksheet("BOT: output")
    except notFound:
    wks2 = mySheet.add_worksheet("BOT: output","999","20")

    Continue reading...

Compartilhe esta Página