diff --git a/README.md b/README.md index 242164e..08cda07 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # bonus-import-tools -bonus-import-tools - -приложение для импорта бонусных баллов \ No newline at end of file +bonus-import-tools + +приложение для импорта бонусных баллов + +python 3.11 \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 0000000..2e5bb4d --- /dev/null +++ b/app.py @@ -0,0 +1,46 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# __author__ = 'szhdanoff@gmail.com' +import os +import csv + +csv_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'csv') + +files = [] +# r=root, d=directories, f = files +for r, d, f in os.walk(csv_path): + for file in f: + filename, file_extension = os.path.splitext(file) + if file_extension == '.csv': + files.append(os.path.join(r, file)) + +for f in files: + with open(f + '.log', "w", encoding="utf-8") as log_file: + with open(f, "r", encoding="utf-8") as csv_file: + csv_reader = csv.reader(csv_file, delimiter=',') + line_count = 0 + name, wallet, value = '', '', '' + for row in csv_reader: + if line_count == 0: + line_count += 1 + else: + name, wallet, value = row[0].strip(), row[1].strip(), row[2].strip() + value = value.replace(',', '.') + value = value.replace(chr(160), '') + if value == '0': + value = '' + line_count += 1 + + ret = 'no tx' + if len(wallet) > 0 and len(value) > 0: + # wallet = w3.toChecksumAddress(wallet.lower()) + # ret = send_joys(c.sender_wallet, _key, wallet, value) + + print(name, wallet, value) + # log_file.write(f'{wallet}{chr9}{value}{chr9}{ret}\n') + log_file.write(f'{ret}\n') + + csv_file.close() + log_file.close() + + os.rename(f, f + '.old') diff --git a/csv/.gitkeep b/csv/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/csv/example.csv.examples b/csv/example.csv.examples new file mode 100644 index 0000000..2f1f250 --- /dev/null +++ b/csv/example.csv.examples @@ -0,0 +1,3 @@ +org_id,user_id,date_time,balance_up, balance_down +8545,6548,"19920,53","19920,53", +,,,, \ No newline at end of file