lunarflu HF staff commited on
Commit
3d8b513
1 Parent(s): 1133d15

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -51,16 +51,24 @@ async def on_ready():
51
  print(f'Logged in as {bot.user.name}')
52
  print(f"XP_PER_MESSAGE: {XP_PER_MESSAGE}")
53
  # testing sheet -> read -> paste sheet
54
- worksheet_test = gspread_bot.open("test").sheet1
55
  #worksheet = gspread_bot.open("levelbot").sheet1
56
 
57
  URL_test = "https://docs.google.com/spreadsheets/d/1hQSsIg1Y9WdBF_CdNM1L1rUUREoxKqRTe3_ILo-WK8w/edit#gid=0"
58
  csv_url_test = URL.replace('/edit#gid=', '/export?format=csv&gid=')
 
59
  response = requests.get(csv_url_test)
60
  if response.status_code == 200:
61
  csv_content = response.text
62
- print(csv_content)
63
- worksheet_test.update('A1', csv_content)
 
 
 
 
 
 
 
64
 
65
 
66
  def calculate_level(xp):
 
51
  print(f'Logged in as {bot.user.name}')
52
  print(f"XP_PER_MESSAGE: {XP_PER_MESSAGE}")
53
  # testing sheet -> read -> paste sheet
54
+
55
  #worksheet = gspread_bot.open("levelbot").sheet1
56
 
57
  URL_test = "https://docs.google.com/spreadsheets/d/1hQSsIg1Y9WdBF_CdNM1L1rUUREoxKqRTe3_ILo-WK8w/edit#gid=0"
58
  csv_url_test = URL.replace('/edit#gid=', '/export?format=csv&gid=')
59
+
60
  response = requests.get(csv_url_test)
61
  if response.status_code == 200:
62
  csv_content = response.text
63
+ csv_file = 'import.csv'
64
+ with open(csv_file, 'w', newline='') as file:
65
+ writer = csv.writer(file)
66
+ for row in csv_content:
67
+ writer.writerow(row)
68
+
69
+ csv_content = open('import.csv', 'r').read()
70
+ worksheet_test = gspread_bot.open("test").sheet1
71
+ gspread_bot.import_csv(worksheet_test.id, csv_content)
72
 
73
 
74
  def calculate_level(xp):