mirror of
https://git.auk.su/Dinect/bonus-import-tools.git
synced 2025-12-29 02:20:02 +00:00
fixed separate reading of files
This commit is contained in:
27
app.py
27
app.py
@@ -34,6 +34,9 @@ for r, d, f in os.walk(csv_path):
|
|||||||
for f in files:
|
for f in files:
|
||||||
with open(f + '.log', "w", encoding="utf-8") as log_file:
|
with open(f + '.log', "w", encoding="utf-8") as log_file:
|
||||||
with open(f, "r", encoding="utf-8") as csv_file:
|
with open(f, "r", encoding="utf-8") as csv_file:
|
||||||
|
file_name = os.path.basename(f)
|
||||||
|
if 'users' in file_name:
|
||||||
|
print(f'Processing "users" file: {f}')
|
||||||
csv_reader = csv.reader(csv_file, delimiter=',')
|
csv_reader = csv.reader(csv_file, delimiter=',')
|
||||||
line_count = 0
|
line_count = 0
|
||||||
for row in csv_reader:
|
for row in csv_reader:
|
||||||
@@ -41,21 +44,29 @@ for f in files:
|
|||||||
line_count += 1
|
line_count += 1
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
nickname, card, phone, summ_total, summ_discount, sum_with_discount, bonus_amount, transaction_date, transaction_time = row
|
|
||||||
print(f'Processing line {line_count}: {row}')
|
print(f'Processing line {line_count}: {row}')
|
||||||
|
nickname, full_name, card, phone, email, gender = row
|
||||||
line_count += 1
|
line_count += 1
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
ret = f'error in line: [{line_count}] {repr(e)}'
|
ret = f'error in line: [{line_count}] {repr(e)}'
|
||||||
log_file.write(f'{ret}\n')
|
log_file.write(f'{ret}\n')
|
||||||
|
|
||||||
# name, wallet, value = row[0].strip(), row[1].strip(), row[2].strip()
|
if 'transaction' in file_name:
|
||||||
# value = value.replace(',', '.')
|
print(f'Processing "transaction" file: {f}')
|
||||||
# value = value.replace(chr(160), '')
|
csv_reader = csv.reader(csv_file, delimiter=',')
|
||||||
# if value == '0':
|
line_count = 0
|
||||||
# value = ''
|
for row in csv_reader:
|
||||||
|
if line_count == 0:
|
||||||
|
line_count += 1
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
print(f'Processing line {line_count}: {row}')
|
||||||
|
user_id, card, phone, summ_total, summ_discount, sum_with_discount, bonus_amount, transaction_date, transaction_time = row
|
||||||
|
line_count += 1
|
||||||
|
|
||||||
# log_file.write(f'{wallet}{chr9}{value}{chr9}{ret}\n')
|
except ValueError as e:
|
||||||
# log_file.write(f'{ret}\n')
|
ret = f'error in line: [{line_count}] {repr(e)}'
|
||||||
|
log_file.write(f'{ret}\n')
|
||||||
|
|
||||||
csv_file.close()
|
csv_file.close()
|
||||||
log_file.close()
|
log_file.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user