-
Notifications
You must be signed in to change notification settings - Fork 0
/
loaddb.py
35 lines (28 loc) · 839 Bytes
/
loaddb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import db
import sys
import csv
if __name__ == '__main__':
if len(sys.argv) < 2:
file = "claim.csv"
else:
file = sys.argv[1]
with open(file, newline='') as csvfile:
spamreader = csv.reader(csvfile, delimiter=',')
total = 0
errored = 0
for row in spamreader:
valid = False
if len(row) < 2:
errored += 1
continue
try:
balance = str(row[1])
valid = True
except:
print ("cant convert", row)
errored += 1
continue
db.set_claimable(row[0], row[1])
total += 1
print("Finished loading db with ", total, " values")
print(errored, " values failed to store")