Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
|
@@ -347,16 +347,55 @@ async def test3(ctx):
|
|
| 347 |
if ctx.author.id == 811235357663297546:
|
| 348 |
worksheet = gspread_bot.open("levelbot").sheet1
|
| 349 |
values = worksheet.get_all_values()
|
|
|
|
| 350 |
|
| 351 |
csv_file_path = 'test3.csv'
|
| 352 |
with open(csv_file_path, 'w', newline='') as csv_file:
|
| 353 |
csv_writer = csv.writer(csv_file)
|
| 354 |
csv_writer.writerows(values)
|
| 355 |
|
|
|
|
| 356 |
with open(csv_file_path, 'r') as csv_file:
|
| 357 |
csv_reader = csv.reader(csv_file)
|
| 358 |
-
|
| 359 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 360 |
|
| 361 |
|
| 362 |
"""
|
|
|
|
| 347 |
if ctx.author.id == 811235357663297546:
|
| 348 |
worksheet = gspread_bot.open("levelbot").sheet1
|
| 349 |
values = worksheet.get_all_values()
|
| 350 |
+
target_id = 811235357663297546
|
| 351 |
|
| 352 |
csv_file_path = 'test3.csv'
|
| 353 |
with open(csv_file_path, 'w', newline='') as csv_file:
|
| 354 |
csv_writer = csv.writer(csv_file)
|
| 355 |
csv_writer.writerows(values)
|
| 356 |
|
| 357 |
+
# print first 5 as test
|
| 358 |
with open(csv_file_path, 'r') as csv_file:
|
| 359 |
csv_reader = csv.reader(csv_file)
|
| 360 |
+
rows = list(csv_reader)
|
| 361 |
+
|
| 362 |
+
for r in range(5):
|
| 363 |
+
row = next(csv_reader, None)
|
| 364 |
+
if row is not None:
|
| 365 |
+
print(row)
|
| 366 |
+
else:
|
| 367 |
+
break
|
| 368 |
+
|
| 369 |
+
|
| 370 |
+
|
| 371 |
+
for row in rows:
|
| 372 |
+
if target_id in row:
|
| 373 |
+
index_of_target = row.index(target_id)
|
| 374 |
+
|
| 375 |
+
# 2 to right
|
| 376 |
+
cell_to_increment_index = index_of_target + 2
|
| 377 |
+
|
| 378 |
+
# +10
|
| 379 |
+
try:
|
| 380 |
+
row[cell_to_increment_index] = str(int(row[cell_to_increment_index]) + 10)
|
| 381 |
+
print(row[cell_to_increment_index])
|
| 382 |
+
except (IndexError, ValueError):
|
| 383 |
+
print(f"Error: Unable to increment cell at index {cell_to_increment_index}")
|
| 384 |
+
|
| 385 |
+
break
|
| 386 |
+
|
| 387 |
+
|
| 388 |
+
|
| 389 |
+
|
| 390 |
+
|
| 391 |
+
|
| 392 |
+
# do simple operation on file (change one value)
|
| 393 |
+
|
| 394 |
+
# post current version to discord
|
| 395 |
+
|
| 396 |
+
# recover csv from discord channel, read into memory
|
| 397 |
+
|
| 398 |
+
|
| 399 |
|
| 400 |
|
| 401 |
"""
|