0

When I download one of my Google Sheets to csv, it removes the proceeding "0" from my values. For example, "0666666" will become "666666". How can I modify the code below so that it keeps that front zeros? Thanks!

def static_tabs():
    static_tabs = ('Locating Media','Schedules')
    for tab in static_tabs:
        edit_ws = edit.worksheet(tab)
        print ("EDIT"+format(edit_ws))
        filename = str(tab) +'.csv' 
        with open('C:/Users/A_DO/Dropbox/2. The Machine/10. Edit and QC Google Doc/Edit/Static Tabs/' + filename, 'wb') as f:
            writer = csv.writer(f,quoting=csv.QUOTE_ALL)
            writer.writerows(edit_ws.get_all_values())

static_tabs()
Andy Do
  • 99
  • 1
  • 2
  • 14

1 Answers1

0

It's not your script that's removing the leading 0s, it's Excel.

Try opening the CSV file in a text editor - you can just use Notepad or Notepad++ if you're on Windows - and you'll see that the leading 0s are actually there.

duffn
  • 3,690
  • 8
  • 33
  • 68