#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import sys
def main():
summ_s_row_now = int(0)
line_iters = int(0)
row_iters = int(0)
str_res_line = str()
int_tpl_data = dict()
with open('in.csv', 'r', encoding='utf-8') as infile, open('out.csv', 'w', encoding='utf-8') as outfile:
for row_now in infile:
str_res_line = str(row_now.split(";")[0])
for i,s_row_now in enumerate(row_now.split(";")[1:]):
if int_tpl_data.get(i):
int_tpl_data[i] += int(s_row_now)
else:
int_tpl_data[i] = int(s_row_now)
summ_s_row_now += int(s_row_now)
str_res_line += str(f""", {s_row_now}""").replace("\n", "")
line_iters += 1
int_tpl_data[line_iters + 1] = round(summ_s_row_now/line_iters,2)
str_to_file = str(f"""{str_res_line}, {int_tpl_data[line_iters + 1]}\n""")
outfile.write(str_to_file)
print(str_to_file)
summ_s_row_now = 0
line_iters = 0
row_iters += 1
outfile.write(f"""SUMM/{row_iters}""")
print(f"""SUMM/{row_iters}""", end = "")
for e,i in enumerate(int_tpl_data,1):
if e == len(int_tpl_data):
continue
str_to_file = str(f""", {round(int_tpl_data[i]/row_iters,2)} """)
outfile.write(str_to_file)
print(str_to_file, end = "")
print()
if __name__ == "__main__":
sys.exit(main())
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys,re
def main(argv=sys.argv):
a = ['Миша', '5', '55', '120', 'Хуан', '0', '4', 'Ваня', '6', '4', '1', 'Педро', '2.35', '3.40']
ss = list()
ss1 = list()
for i in a:
if not re.search(r"\d",str(i)):
if ss1:
ss.append(tuple(ss1))
ss1 = list()
ss1.append(i)
else:
ss1.append(i)
ss.append(tuple(ss1))
print(ss)
if __name__ == "__main__":
sys.exit(main())
msg = MIMEMultipart("mixed")
msg['To'] = email_from
msg['From'] = sender_email
msg['Subject'] = Header(str("REsend: " + email_subject), 'UTF-8')
msg.attach( MIMEText(body_to_send_part_1, "html", _charset='UTF-8') )
msg.attach(full_mail)
smtp_descprt.sendmail(sender_email, [email_from], msg.as_bytes())