Skip to content

Commit f7cba6d

Browse files
load dataframe as csv (write_data_to_table)
1 parent 83c52f1 commit f7cba6d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

common_grade_export/src/utils/gspread.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import csv
22
import os
3+
from io import StringIO
34

45
import pandas as pd
56
import pygsheets
@@ -43,7 +44,11 @@ def write_data_to_table(
4344

4445
wk_content = sh.worksheet_by_title(sheet_name)
4546

46-
wk_content.set_dataframe(df_data, "A1", copy_head=True)
47+
# wk_content.set_dataframe(df_data, "A1", copy_head=True) # problem w/float dot
48+
csv_data = df_data.to_csv(sep=',', encoding='utf-8', decimal=',')
49+
reader = csv.reader(csv_data, delimiter=',')
50+
for index, row in enumerate(reader, start=1):
51+
wk_content.append_table(row, start=f'A{index}', overwrite=True)
4752

4853

4954
def add_csv_to_table_dis(

0 commit comments

Comments
 (0)