lunarflu HF staff commited on
Commit
941dced
1 Parent(s): fa7064d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -15
app.py CHANGED
@@ -51,7 +51,8 @@ api = HfApi()
51
  #csv_file = 'data.csv'
52
  global_df = pd.DataFrame()
53
  print(type(global_df))
54
-
 
55
 
56
  @bot.event
57
  async def on_ready():
@@ -61,8 +62,6 @@ async def on_ready():
61
  # testing sheet -> read -> paste sheet
62
 
63
  """import data from google sheets -> HF Space .csv (doesn't make API call this way, as it's read-only)"""
64
- data = pd.read_csv("https://docs.google.com/spreadsheets/d/1hQSsIg1Y9WdBF_CdNM1L1rUUREoxKqRTe3_ILo-WK8w/export?format=csv&gid=0")
65
- print(data)
66
  data['discord_user_id'] = data['discord_user_id'].astype(str)
67
  print(data)
68
  global_df = data
@@ -213,11 +212,11 @@ async def add_exp(member_id):
213
  xp = 10 # define somewhere else?
214
  current_level = calculate_level(xp)
215
  member_name = member.name
 
216
  print(f"test")
217
  row_data = [member_id, member_name, xp, current_level]
218
  print(f"test")
219
  new_row_df = pd.DataFrame([row_data], columns=global_df.columns)
220
- print(type(global_df))
221
  #updated_df = global_df.append(new_row_df, ignore_index=True) deprecated
222
  updated_df = pd.concat([global_df, pd.DataFrame([new_row_df])], ignore_index=True)
223
  print(f"test")
@@ -336,11 +335,6 @@ async def xp_help(ctx):
336
  # check if members are still in the server
337
 
338
 
339
-
340
-
341
-
342
-
343
-
344
  """"""
345
  DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
346
  def run_bot():
@@ -348,13 +342,11 @@ def run_bot():
348
  threading.Thread(target=run_bot).start()
349
 
350
 
351
- URL = "https://docs.google.com/spreadsheets/d/1hQSsIg1Y9WdBF_CdNM1L1rUUREoxKqRTe3_ILo-WK8w/edit#gid=0"
352
- csv_url = URL.replace('/edit#gid=', '/export?format=csv&gid=')
353
-
354
-
355
  def get_data():
356
- data = pd.read_csv(csv_url)
357
- first_3_columns = data.iloc[:, 1:4]
 
 
358
  first_3_columns.to_csv('first_3_columns.csv', index=False)
359
  return first_3_columns
360
  # csv
 
51
  #csv_file = 'data.csv'
52
  global_df = pd.DataFrame()
53
  print(type(global_df))
54
+ data = pd.read_csv("https://docs.google.com/spreadsheets/d/1hQSsIg1Y9WdBF_CdNM1L1rUUREoxKqRTe3_ILo-WK8w/export?format=csv&gid=0")
55
+ print(data)
56
 
57
  @bot.event
58
  async def on_ready():
 
62
  # testing sheet -> read -> paste sheet
63
 
64
  """import data from google sheets -> HF Space .csv (doesn't make API call this way, as it's read-only)"""
 
 
65
  data['discord_user_id'] = data['discord_user_id'].astype(str)
66
  print(data)
67
  global_df = data
 
212
  xp = 10 # define somewhere else?
213
  current_level = calculate_level(xp)
214
  member_name = member.name
215
+ member_id_str = str(member_id)
216
  print(f"test")
217
  row_data = [member_id, member_name, xp, current_level]
218
  print(f"test")
219
  new_row_df = pd.DataFrame([row_data], columns=global_df.columns)
 
220
  #updated_df = global_df.append(new_row_df, ignore_index=True) deprecated
221
  updated_df = pd.concat([global_df, pd.DataFrame([new_row_df])], ignore_index=True)
222
  print(f"test")
 
335
  # check if members are still in the server
336
 
337
 
 
 
 
 
 
338
  """"""
339
  DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
340
  def run_bot():
 
342
  threading.Thread(target=run_bot).start()
343
 
344
 
 
 
 
 
345
  def get_data():
346
+ URL = "https://docs.google.com/spreadsheets/d/1hQSsIg1Y9WdBF_CdNM1L1rUUREoxKqRTe3_ILo-WK8w/edit#gid=0"
347
+ csv_url = URL.replace('/edit#gid=', '/export?format=csv&gid=')
348
+ getdata = pd.read_csv(csv_url)
349
+ first_3_columns = getdata.iloc[:, 1:4]
350
  first_3_columns.to_csv('first_3_columns.csv', index=False)
351
  return first_3_columns
352
  # csv