spl_csv_search.py 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # Program to search through Solscan
  2. # TODO:
  3. # 1) Program donwloading history of solscan into csv according given parameters
  4. # 2) Program exploring the alle, txhash, amont, time etc
  5. # 3) API remote controllng program
  6. import csv
  7. from datetime import datetime
  8. def get_info():
  9. """Functiong extractiong info from the downloaded csv file"""
  10. filename = 'data/export_transfer_undefined_1654954858887.csv'
  11. with open(filename) as f:
  12. reader = csv.reader(f)
  13. header_row = next(reader)
  14. # This passes the next line (1st = header)
  15. # for index, column_header in enumerate(header_row):
  16. # print(index, column_header)
  17. times, txhashes, amounts, source_owners, dest_owners = [], [], [], [], [],
  18. for row in reader:
  19. time_index = header_row.index('BlockTime')
  20. txhash_index = header_row.index('TxHash')
  21. amount_index = header_row.index('Amount')
  22. source_own_index = header_row.index('Source Owner Account')
  23. dest_own_index = header_row.index('Dest Owner Account')
  24. try:
  25. txhash = str(row[txhash_index])
  26. amount = float(row[amount_index])
  27. src_own = str(row[source_own_index])
  28. dst_own = str(row[dest_own_index])
  29. date_time = f"{row[time_index]}"
  30. # hover_date_time = \
  31. # datetime.strptime(date_time, '%Y-%m-%d, %H%M')
  32. except IndexError:
  33. print(f"Missing data")
  34. else:
  35. times.append(date_time)
  36. txhashes.append(txhash)
  37. amounts.append(amount)
  38. source_owners.append(src_own)
  39. dest_owners.append(dst_own)
  40. return times, txhashes, amounts, source_owners, dest_owners
  41. def display_csv_txs_usdt(min=1000000,max=10000000):
  42. """Prints all tx's within the range of entered amount"""
  43. _print_header_txs_usdt(min,max)
  44. times, txhashes, amounts, source_owners, dest_owners = get_info()
  45. for index,amount in enumerate(amounts):
  46. usdt = amount/1000000
  47. i = index
  48. txhash = txhashes[i]
  49. src_own = source_owners[i]
  50. dst_own = dest_owners[i]
  51. time = times[i]
  52. if usdt > min and usdt < max:
  53. print(\
  54. f"{time} - {txhash} - {src_own} - {dst_own} - {usdt}"
  55. )
  56. def _print_header_txs_usdt(min,max):
  57. "Support function to print the header for tx's in usdt"""
  58. print(f"\nTRANSACTIONS BETWEEN {min} and {max} USDT")
  59. print("\n=======================================")
  60. print(\
  61. "\nTIME\t-\t-\t-\t-\t-\t"\
  62. "TXHASH"\
  63. "\t-\t-\t-\t-\t-\t-\t-\t-\t-\t-\t-\t-\t-\t-\t-\t-\t-\t-\t-\t-\t-\t"\
  64. "SOURCE OWNER\t-\t-\t-\t-\t-\t-\t-\t"\
  65. "DESTINATION OWNER\t-\t-\t-\t-\t-\t-\t-\t"\
  66. "AMOUNT (USDT)\n"
  67. )
  68. display_csv_txs_usdt(10000000,100000000)