I followed this answer to this question (Appending pandas Data Frame to Google spreadsheet) to append by dataframe to an empty google spreadheet. Some data is being added to it but not how I want:
code:
#complete_dict is just a dictionary I created from JSON
df = pd.DataFrame(complete_dict).fillna(value='0').T
convert_to_csv = df.to_csv('C:/Users/Elitebook/Documents/GitHub/test3.csv')
print df
scope = ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive']
credentials = ServiceAccountCredentials.from_json_keyfile_name('C:/Users/Elitebook/Documents/GitHub/TrackRev-caad86be6e44.json', scope)
file = gspread.authorize(credentials)
#create the empty spreadsheet
new_spreadsheet = file.create('CSV-test-6')
#this step is necessary so we can view the spreadsheet
new_spreadsheet.share("charlesdsmith25@gmail.com", perm_type='user', role='writer')
#after the spreadsheet is created, open it
spreadsheet = file.open('CSV-test-6').sheet1
existing = gd.get_as_dataframe(spreadsheet)
updated = existing.append(df)
df_spreadsheet = set_with_dataframe(spreadsheet, updated)
This is what my dataframe looks like:
add_classes add_grades change_classes ... delete_grades view_classes view_grades
principle 1 0 1 ... 0 1 1
student1 0 0 0 ... 0 1 1
student2 0 0 0 ... 0 1 1
teacher 0 1 0 ... 1 1 1
But this is what the spreadsheet looks like:
Unnamed: 0 Unnamed: 1 Unnamed: 10 Unnamed: 11 Unnamed: 12 Unnamed: 13 Unnamed: 14 Unnamed: 15 Unnamed: 16 Unnamed: 17 Unnamed: 18 Unnamed: 19 Unnamed: 2 Unnamed: 20 Unnamed: 21 Unnamed: 22 Unnamed: 23 Unnamed: 24 Unnamed: 25 Unnamed: 3 Unnamed: 4 Unnamed: 5 Unnamed: 6 Unnamed: 7 Unnamed: 8 Unnamed: 9 add_classes add_grades change_classes change_grades delete_classes delete_grades view_classes view_grades
No rows and way too many columns and the values (1s and 0s) aren't there