code "def main(table): new_table = [] for row in table: if row not in new_table: new_table.append(row) table_2 = [] zip_table = zip(*new_table) for row in zip_table: if row not in table_2: table_2.append(row) table_2 = zip(*table_2) table_2 = [list(row) for row in table_2] for i in range(len(table_2)): (date, mail) = table_2[i][0].split('#') table_2[i][0] = mail.replace('[at]', '@') table_2[i].append(date.split('/')[0]) table_2[i][1] = table_2[i][1].replace(' ', '').replace('-', '') table_2 = zip(*table_2) table_2 = [list(row) for row in table_2] return table_2" "def main(s): s = list(map(list, zip(*s))) s.pop(1) s.pop(2) s.append([]) for i in range(len(s) - 1): for j in range(len(s[i])): if i == 0: t = s[i][j].find('!') if s[i][j][t - 1:t] == 'Y': s[len(s) - 1].append('Выполнено') else: s[len(s) - 1].append('Не выполнено') s[i][j] = s[i][j][t + 1:] s[i][j] = s[i][j].replace('[at]', '@') elif i == 1: s[i][j] = ' '.join(s[i][j].split(' ')[::-1]) elif i == 2: s[i][j] = '/'.join(s[i][j].split('-')[::-1]) return s" "def main(start_l): f = [] named = [] bools = [] nums = [] for (i, v) in enumerate(start_l): tmp_named = v[0].split(',') (tmp_named[0], tmp_named[1]) = (tmp_named[1][1:3], ' ' + tmp_named[0]) named.append(''.join(tmp_named)) tmp_bool = 'да' if v[1] == 'true' else 'нет' bools.append(tmp_bool) tmp_num = v[2] + '00' nums.append(tmp_num) f.append(named) f.append(bools) f.append(nums) return f" "def unique(lst): buf = [] for i in lst: if i not in buf: buf.append(i) return buf def main(input_table): input_table = unique(input_table) output_table = [] for i in input_table: output_table.append([i[0].split('|')[0], i[1], i[0].split('|')[1]]) for i in output_table: i[0] = i[0][2] + i[0][3] + i[0][4] + '-' + i[0][5] + i[0][6] + i[0][7] + '-' + i[0][8] + i[0][9] + i[0][10] + i[0][11] splitted = i[1].split(' ') i[1] = splitted[0][0] + '.' + splitted[1] + ' ' + splitted[2] i[2] = i[2][:6] + i[2][8:] output_table = sorted(output_table) return output_table" "def main(tb): tmp_tb = [] for y in tb: t = [] for x in y: if x is not None: t.append(x) tmp_tb.append(t) for i in range(len(tmp_tb)): tmp_tb[i][0] = tmp_tb[i][0].replace(' ', '') tmp_tb[i][0] = tmp_tb[i][0].replace('-', '') tmp_tb[i][0] = tmp_tb[i][0].replace('+', '')[1:] tmp_tb[i][1] = str(round(float(tmp_tb[i][1]), 1)) tmp_tb[i][2] = tmp_tb[i][2].split() for i in range(len(tmp_tb)): tmp_tb[i][0] = tmp_tb[i][0][0:3] + '-' + tmp_tb[i][0][3:6] + '-' + tmp_tb[i][0][6:] t = tmp_tb[i][2][2] + ' ' + tmp_tb[i][2][0][0] + '.' + tmp_tb[i][2][1] tmp_tb[i][2] = t tb2 = [[None for _ in range(len(tmp_tb))] for _ in range(len(tmp_tb[0]))] for y in range(len(tmp_tb)): for x in range(len(tmp_tb[y])): tb2[x][y] = tmp_tb[y][x] return tb2" "from collections import OrderedDict from itertools import groupby def remove_duplicated_rows(lst): return list(OrderedDict(((tuple(x), x) for x in lst)).values()) def remove_empty_columns(lst): data = zip(*lst) data = [x for x in data if any(x)] return list(map(list, zip(*data))) def transpose(lst): return list(map(list, zip(*lst))) def remove_duplicated_columns(lst): data = zip(*lst) data = [x for x in data if not all_equal(x)] return list(map(list, zip(*data))) def all_equal(iterable): g = groupby(iterable) return next(g, True) and (not next(g, False)) def remove_empty_rows(lst): for ls in lst: if all_equal(ls) and ls[0] is None: lst.remove(ls) return lst def split_column_one_and_transform(lst): for ls in lst: src = ls[0] last_name = src[:src.find(',')] ls[0] = last_name ls.insert(1, '{:.1f}'.format(float(src[src.find(':') + 1:]))) ls[2] = ls[2].replace('.', '/') ls[3] = ls[3].replace('Y', 'да').replace('N', 'нет') ls.pop(-1) return lst def main(lst): lst = remove_duplicated_columns(lst) lst = remove_empty_columns(lst) lst = remove_duplicated_rows(lst) lst = remove_empty_rows(lst) lst = split_column_one_and_transform(lst) lst = transpose(lst) return lst" "import re def main(table): result = {} for v in table: if v[0] is None: continue n = v[2].split('!') result[n[0]] = ['0' if v[0] == 'false' else '1', re.sub('\\..\\.', '.', n[0]), n[1].split(' ')[1].replace('-', '')] return list(map(list, zip(*list(sorted(result.values(), key=lambda v: v[1])))))" "def main(a): b = [] temp = [] for i in range(len(a)): temp.append(a[i][0][5:]) b.append(temp) temp = [] for i in range(len(a)): temp.append(str(round(float(a[i][1]), 1))) b.append(temp) temp = [] for i in range(len(a)): temp.append('/'.join(a[i][2].split('-'))) b.append(temp) temp = [] for i in range(len(a)): t = a[i][3].split(' ') temp.append(f'{t[2]} {t[0][0]}.{t[1]}') b.append(temp) return b" "def main(table): parsed = set() (percent, state, datedot) = ([], [], []) for (num, flag, _, date) in table: if num in parsed or num is None: continue parsed.add(num) percent.append(f'{float(num):.0%}') state.append('Выполнено' if int(flag) else 'Не выполнено') datedot.append(f'{date[-2:]}.{date[3:5]}.{date[:2]}') return [percent, state, datedot]" "import re def main(a): for i in range(len(a)): a[i].pop(1) string = a[i][0].split() a[i][0] = string[1] + ' ' + string[0] string = a[i][1] string = re.split('-| ', string) a[i][1] = string[1] + string[2] + string[3] string = a[i][2].split('/') a[i][2] = string[0][2:] + '-' + string[1] + '-' + string[2] rem = list() for i in range(len(a) - 1): for q in range(i + 1, len(a)): if a[i] == a[q]: if q not in rem: rem.append(q) rem.sort() rem.reverse() for i in rem: a.pop(i) b = list() for i in range(len(a[0])): b.append(list()) for q in range(len(a)): b[i].append(0) b[i][q] = a[q][i] return b" "import re def main(old_table): empty_row = [None for col in range(len(old_table[0]))] new_table = [] for i in old_table: first = 0 for c in range(len(old_table)): if (i == old_table[c]) & (first == 0): first += 1 continue elif i == old_table[c]: old_table[c] = empty_row for i in old_table: if i != empty_row: i[0] = str(round(float(i[0]), 1)) i[1] = re.split(' *\\[at\\]', i[1]) i[1] = i[1][0] + '@' + i[1][1] i[2] = re.split('\\, |\\.', i[2]) i[2] = i[2][1] + '. ' + i[2][0] i[3] = i[3].lower() new_table.append(i) else: continue row_len = len(new_table[0]) col_len = len(new_table) return [[new_table[j][i] for j in range(col_len)] for i in range(row_len)]" "def main(a): res = list() tmp1 = list() tmp2 = list() tmp3 = list() tmp4 = list() for i in range(len(a)): tmp = a[i][0].split() tmp1.append(f'({tmp[1]}) {tmp[2]}') res.append(tmp1) for i in range(len(a)): tmp = a[i][1][0] s = 'да' if tmp == 'Y' else 'нет' tmp2.append(s) res.append(tmp2) for i in range(len(a)): tmp = a[i][2].split('-') tmp3.append(f'{tmp[0]}-{tmp[1]}-{tmp[2][2:]}') res.append(tmp3) for i in range(len(a)): tmp = a[i][1][2:-2].split(',') tmp4.append(f'{tmp[0]}{tmp[1]}') res.append(tmp4) return res" "def f(lst): n = [] for i in lst: if i not in n: n.append(i) return n def func(string): string = string.split(' ') string = str(string[1][0] + '. ' + string[0]) return string def main(data: list): data = f(data) for i in range(len(data)): data[i][0] = data[i][0].split(' ')[1] data[i][1] = data[i][1].replace(',', '') data[i][1] = func(data[i][1]) data[i][2] = data[i][2] + '0' data[i][3] = data[i][3].split('.')[0] return data" "def main(list1): l1 = [] ls = [] list2 = [] list1 = [[x for x in y if x is not None] for y in list1] list1 = [x for x in list1 if x != []] a = len(list1) b = len(list1[0]) for i in range(0, b + 1): list2.append([0] * a) for i in range(len(list1)): lst = list1[i] lst[0] = lst[0][3:] lst[0] = lst[0].replace(' ', '-') lst[0] = lst[0][:10] + lst[0][10 + 1:] list1[i] = lst lst = list1[i] s = lst[1][11:] s += '00' l1.append(s) s1 = lst[1][2:10] s1 = s1.replace('/', '.') s1 = s1[6:8] + '.' + s1[3:6] + s1[0:2] ls.append(s1) for i in range(len(list2[0])): list2[0][i] = list1[i][0] list2[1][i] = l1[i] list2[2][i] = ls[i] return list2" "import re def main(input): output = [] for i in range(len(input)): output.append([]) phonePattern = '\\+(\\d)(\\d\\d\\d)(\\d\\d\\d)(\\d\\d)(\\d\\d)' phone = re.findall(phonePattern, input[i][0])[0] output[i].append('+' + phone[0] + ' ' + phone[1] + ' ' + phone[2] + '-' + phone[3] + '-' + phone[4]) mail = re.findall('(.+)\\[', input[i][3])[0] output[i].append(mail) pattern = '(\\d\\d)\\.(\\d\\d)\\.(\\d\\d):(\\S*) .\\. (\\S*)' (day, month, year, name, surname) = re.findall(pattern, input[i][4])[0] output[i].append(surname + ' ' + name) output[i].append(day + '/' + month + '/' + year) return sorted(output, key=lambda row: row[1])" "from datetime import datetime def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def replace(lst): for (key, value) in enumerate(lst[0]): lst[0][key] = '{:.4f}'.format(float(lst[0][key])) for (key, value) in enumerate(lst[3]): lst[3][key] = lst[3][key].replace('1', 'Выполнено') lst[3][key] = lst[3][key].replace('0', 'Не выполнено') for (key, value) in enumerate(lst[2]): datetime_object = datetime.strptime(lst[2][key], '%d/%m/%Y') lst[2][key] = datetime_object.strftime('%y.%m.%d') for (key, value) in enumerate(lst[1]): lst[1][key] = lst[1][key].replace('(', ' ') lst[1][key] = lst[1][key].replace(')', ' ') return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = replace(lst) return lst" "def main(table): parsed = set() (domain, surname, score_round) = ([], [], []) for (email_name, score) in table: if email_name in parsed and email_name is not None: continue parsed.add(email_name) domain.append(email_name.split(':')[0].split('@')[1]) surname.append(email_name.split(':')[1].split(' ')[0]) score_round.append(str(round(float(score), 1))) return [domain, surname, score_round]" "import math import datetime as DT def main(table): for i in range(0, len(table)): table[i].pop(0) table1 = [] for i in table: if i not in table1: table1.append(i) for i in range(len(table1)): table1[i][0] = str(round(float(table1[i][0]) * 100)) + '%' table1[i][1] = table1[i][1].replace(' ', '(', 1) table1[i][1] = table1[i][1].replace(' ', ') ') table1[i][1] = table1[i][1].replace('+7', '') table1[i][1] = '{}-{}'.format(table1[i][1][:12], table1[i][1][12:]) date = DT.datetime.strptime(table1[i][2], '%d.%m.%Y').date() table1[i][2] = date.strftime('%d-%m-%y') table = [list(x) for x in zip(*table1)] return table" "def delsame(x): k = 0 for i in range(len(x) - k): j = 1 while j + i < len(x): if x[i][0] == x[i + j][0]: k += 1 del x[i + j] else: j += 1 return x def transp(x): ans = [] for i in range(len(x[0])): temp = [] for j in range(len(x)): temp.append(x[j][i]) ans.append(temp) return ans def main(a): x = [] for i in a: if i[2] is None: del i else: b = i[2].split(';') del i[2] x.append(list(set(i)) + b) x = delsame(x) ans = transp(x) for i in range(len(ans[1])): ans[1][i] = ans[1][i][:ans[1][i].find('@')] for i in range(len(ans[0])): c = ans[0][i].split() ans[0][i] = str(c[1]) + ' ' + str(c[0]) for i in range(len(ans[-1])): ans[-1][i] = ans[-1][i][2:] return ans" "from collections import OrderedDict def f(matr): result = [] for i in range(len(matr)): if None not in matr[i] and list(OrderedDict.fromkeys(matr[i])) not in result and (len(matr[i]) != 0): result.append(list(OrderedDict.fromkeys(matr[i]))) for i in range(len(result)): result[i][0] = str(round(float(result[i][0]), 1)) result[i][1] = result[i][1][2:].replace('.', '-') result[i][2] = result[i][2][result[i][2].index('@') + 1:] temp = list(OrderedDict.fromkeys(result[i]))[3].split() result[i][3] = temp[1] + ' ' + temp[0] result = list(map(list, zip(*result))) return result def main(matr): return f(matr)" "def main(table): parsed = set() result = [] for (ans, _, _, _, data) in table: (answer, date, fullname) = ([], [], []) if data in parsed and data is not None: continue parsed.add(data) answer.append('да' if ans == 'Y' else 'нет') pdate = data.split('&')[0].split('-') date.append(f'{pdate[2][2:]}/{pdate[1]}/{pdate[0]}') fname = data.split('&')[1].split(' ') fullname.append(f'{fname[2]}, {fname[0][0]}.{fname[1]}') result.append([answer[0], date[0], fullname[0]]) return result" "from typing import List def clear_nones(strings: List) -> List: result = [] for string in strings: check = [item is None for item in string] if True not in check: result.append(string) return result def clear_duplicates(strings: List) -> List: result = [] united = [] cash = [] for string in strings: unification = ''.join(string) united.append(unification) for i in range(len(strings)): if united[i] not in cash: result.append(strings[i]) cash.append(united[i]) return result def get_selected_column(strings: List, column: int) -> List: result = [] for item in strings: if len(item) <= column < 0: continue result.append(item[column]) return result def get_string_percentages(strings: List) -> List: result = [] percentages = get_selected_column(strings, 0) for percent in percentages: value = round(int(percent[:-1]) / 100, 1) if percent[-1] == '%' else round(int(percent) / 100, 1) result.append(str(value)) return result def get_first_part(first_part: str) -> str: number = first_part.split()[-1].split('-') return ''.join(number) def get_second_part(second_part: str) -> str: mail = second_part.split('[at]')[0] return mail def get_string_users(strings: List) -> List: result = [] users = get_selected_column(strings, 1) for user in users: (first_part, second_part) = str(user).split('&') first_part = get_first_part(first_part) second_part = get_second_part(second_part) result.append((first_part, second_part)) return result def get_string_conditions(strings: List) -> List: conditions = get_selected_column(strings, 2) result = ['Да' if condition == 'true' else 'Нет' for condition in conditions] return result def main(table: List) -> List: table = clear_nones(table) table = clear_duplicates(table) percentages = get_string_percentages(table) users = get_string_users(table) conditions = get_string_conditions(table) result_table = [percentages] id_users = [user[0] for user in users] name_users = [user[1] for user in users] result_table.append(id_users) result_table.append(conditions) result_table.append(name_users) return result_table" "def main(table): parsed = set() result = [] for (ans, data, _, score, _) in table: (answer, uuid, score_res, full_name) = ([], [], [], []) if data in parsed or data is None: continue parsed.add(data) answer.append('Выполнено' if ans == 'Y' else 'Не выполнено') puuid = data.split('#')[1].split(' ') uuid.append(f'{puuid[0]}-{puuid[1]}') fname = data.split('#')[0].split(' ') full_name.append(f""{fname[0].replace(',', '')} {fname[1][0]}{fname[1][1]}"") score_res.append(str(round(float(score), 1))) result.append([answer[0], uuid[0], score_res[0], full_name[0]]) return sorted(result, key=lambda x: x[3])" "def main(start_list): new_list = [] for _ in start_list: if _[0] is not None: string = [str(int(float(_[0]) * 100)) + '%', 'Не выполнено' if _[3] == 'Нет' else 'Выполнено', _[4][-4:], _[5][:6] + _[5][6:12] + _[5][-2:]] if string not in new_list: new_list.append(string) return new_list" "def main(tab): a = len(tab) index = find(tab) tab = change1(tab) tab = change2(tab) arr = [0] * 3 for i in range(3): arr[i] = [0] * a for i in range(0, a): arr[0][i] = tab[i][0] arr[1][i] = tab[i][1] arr[2][i] = str(tab[i][index]) + '0' return arr def change1(tab): a = len(tab) for i in range(0, a): sim = tab[i][0].find(']') + 1 tab[i][0] = tab[i][0][sim:] return tab def change2(tab): a = len(tab) for i in range(0, a): if tab[i][1] == 'Да': tab[i][1] = 'Y' elif tab[i][1] == 'Нет': tab[i][1] = 'N' return tab def find(tab): b = len(tab[0]) index = 2 for i in range(2, b): if tab[0][i] is not None: break else: index += 1 return index" "def main(table): parsed = set() result = [] for (date, phone, score) in table: (date_parsed, phone_parsed, score_round) = ([], [], []) if date in parsed or date is None: continue parsed.add(date) date_parsed.append(date.replace('-', '.')) phone = phone[3:] phone_parsed.append(f'{phone[:-4]}-{phone[3:]}') score_round.append(f'{float(score):0.2f}') result.append([date_parsed[0], phone_parsed[0], score_round[0]]) return result" "from pprint import pprint import re def make(table): rows_count = len(table) cols_count = len(table[0]) cols_data = {} rows_data = {} cols_removes = [] rows_removes = [] for i in range(cols_count): res_list = list(map(lambda x: x[i] or '', table)) res = '|'.join(res_list) if not cols_data.get(res): cols_data[res] = True else: cols_removes.append(i) for i in range(rows_count): res_list = list(map(lambda x: x or '', table[i])) res = '|'.join(res_list) if not rows_data.get(res) and res_list.count('') != cols_count: rows_data[res] = True else: rows_removes.append(i) tableAfterRemoveRows = list(map(lambda x: x[1], filter(lambda x: x[0] not in rows_removes, enumerate(table)))) def removeFn(row): return list(map(lambda x: x[1], filter(lambda x: x[0] not in cols_removes, enumerate(row)))) tableAfterRemove = list(map(removeFn, tableAfterRemoveRows)) def splitIndex0(row): item = row[0] row.insert(0, item) row[0] = item.split('#')[0] row[1] = item.split('#')[1] row = row[1:] + row[0:1] return row tableAfterSplit = list(map(splitIndex0, tableAfterRemove)) def transformItem(item): item = str(item) if item.startswith('+'): return str(''.join([char for char in item if re.search('\\d', char)])[1:]) if re.search('^[а-яА-ЯёЁ]', item): return item.split(',')[0] return str(round(float(item), 1)) transformedTable = [list(map(transformItem, row)) for row in tableAfterSplit] sortedList = sorted(transformedTable, key=lambda item: item[2]) transposedTable = list((list(a) for a in zip(*sortedList))) return transposedTable def main(table): return make(table)" "import re def main(a): a = list(map(list, {tuple(x) for x in a})) for i in range(0, len(a)): a[i] = list(set(a[i])) a[i].remove(None) a[i] = sorted(a[i]) a.remove([]) for i in range(0, len(a)): a[i][0] = '%.3f' % float(a[i][0]) a[i][1] = re.split('@', a[i][1])[0] a[i][2] = re.split(' ', a[i][2])[1] (a[i][2], a[i][1]) = (a[i][1], a[i][2]) n = 1 while n < len(a): for i in range(len(a) - n): if a[i][2] > a[i + 1][2]: (a[i], a[i + 1]) = (a[i + 1], a[i]) n += 1 B = [[0] * len(a) for i in range(len(a[0]))] for i in range(0, len(a)): for j in range(0, len(a[i])): B[j][i] = a[i][j] return B" "def tables1(x): f_t = [] for i in x: curr_l = [] for j in range(0, len(i)): if i[j] is None: continue else: curr_l.append(i[j]) if len(curr_l) == 0: continue else: f_t.append(curr_l) return f_t def tables2(x): f_t = [] for i in range(0, len(x)): if x[i] not in f_t: f_t.append(x[i]) else: continue return f_t def tables3(x): f_t = [] for i in range(0, len(x)): curr = [] for j in range(0, len(x[i])): if x[i][j] not in curr: curr.append(x[i][j]) else: continue f_t.append(curr) return f_t def tables4(x): for i in range(0, len(x)): x[i][0] = x[i][0].split('[at]')[0] + '@' + x[i][0].split('[at]')[1] x[i][1] = x[i][1][:3] + ' ' + x[i][1][3:6] + '-' + x[i][1][6:10] for i in range(0, len(x)): for j in range(0, len(x[i])): if x[i][j] == 'false': x[i][j] = 'нет' elif x[i][j] == 'true': x[i][j] = 'да' return x def main(x): return tables4(tables3(tables2(tables1(x))))" "import array from typing import List import copy as cp def main(mat_in: List[List]) -> List[List]: if len(mat_in) < 1: return list() mat_out = [['' for _ in mat_in] for _ in mat_in[0]] for (row_num, row) in enumerate(mat_in): (date_str, fullname, predicate_str) = row mat_out[0][row_num] = ''.join([date_str[:6], date_str[8:]]) (name, surname, patronymic) = str(fullname).split(sep=' ') mat_out[1][row_num] = ''.join([name[0], '.', surname, ' ', patronymic]) mat_out[2][row_num] = '1' if str(predicate_str).lower() == 'да' else '0' return mat_out" "def remove_extra_rows(table): new_table = [] for i in range(len(table)): if table[i] not in new_table and table[i] != [None] * len(table[i]): new_table.append(table[i]) return new_table def divide_first_column(table): for i in range(len(table)): (x, y) = table[i][0].split('|') table[i][0] = x table[i].insert(1, y) return table def transpose(table): new_table = [] for i in range(len(table[0])): line = [] for j in range(len(table)): line.append(table[j][i]) new_table.append(line) return new_table def transform_view(table): for i in range(len(table)): date = table[i][0].split('.') date = [date[-1][2:], date[1], date[0]] table[i][0] = '-'.join(date) table[i][1] = table[i][1].split()[-1] table[i][2] = '%.4f' % float(table[i][2]) return table def main(table): table = transpose(table) table = remove_extra_rows(table) table = transpose(table) table = remove_extra_rows(table) table = divide_first_column(table) table = transform_view(table) table = sorted(table, key=lambda x: x[1]) return table" "def s(string): tmp = [] for item in string: if item not in tmp: tmp.append(item) return tmp def d(i, string): for j in range(len(string)): if i == j: continue if string[i] == string[j]: string[i] = None return string def main(string): for i in range(len(string)): string[i] = s(string[i]) tmp = list(string[i]) for j in range(len(tmp)): if string[i][j] is None: tmp.pop(j) string[i] = tmp for i in range(len(string)): string = d(i, string) string = list(filter(None, string)) for i in range(len(string)): if string[i][1].split(';')[1] == 'Да': string[i].insert(1, '1') else: string[i].insert(1, '0') string[i][2] = string[i][2].split(';')[0] ima = string[i][2].split(' ')[0][0] o = string[i][2].split(' ')[1] string[i][2] = f""{string[i][2].split(' ')[2]} {ima}.{o.upper()}"" string[i][0] = str(round(float(string[i][0]), 1)) return sorted(string, key=lambda x: x[2])" "def unique(seq): seen = set() seen_add = seen.add return [x for x in seq if not (x in seen or seen_add(x))] def main(data): normalized = [] for line in data: if line[0] is not None: additional = line[3].split(';') percentage = round(float(additional[0][:-1]) / 100, 1) date = additional[1].replace('-', '.') normalized.append((line[0].replace('[at]', '@'), line[2][:-2], date, str(percentage))) normalized = unique(normalized) result = [[], [], [], []] for record in normalized: for index in range(len(record)): result[index].append(record[index]) return result" "def main(args): def first(x): return 'Y' if x == 'да' else 'N' if x == 'нет' else None def second(x): return x[x.find('[at]') + 4:] def third(x): return '{:.4f}'.format(float(x)) for i in range(0, len(args)): args[i] = [first(args[i][0]), second(args[i][1]), third(args[i][2])] return args" "def main(x): for i in x: i.pop(3) i.pop(2) j = 0 name = '' while i[0][j] != '.': name += i[0][j] j += 1 name += '.' while i[0][j] != '!': j += 1 new = i[0][j + 8] + i[0][j + 9] + i[0][j + 10] + i[0][j + 12] + i[0][j + 13] + i[0][j + 15] + i[0][j + 16] i[0] = new j = len(i[1]) - 1 new = '' while i[1][j] != ']': new = i[1][j] + new j -= 1 i[1] = new j = 0 new = '' while i[2][j] != '%': new += i[2][j] j += 1 if len(new) == 1: new = '0.0' + new + '00' elif len(new) == 2: new = '0.' + new + '00' elif len(new) == 3: new = new[0] + '.' + new[1] + new[2] + '00' i[2] = new new = '' i.append(name) return x" "import re def main(table): empty_row = [None for col in range(len(table[0]))] new_table = [] for i in table: first = True for c in range(len(table)): if (i == table[c]) & first: first = False continue elif i == table[c]: table[c] = empty_row for i in table: if i != empty_row: i[0] = str(i[0]) + '0' i[1] = i[1].lower() i[2] = re.split('[\\(\\)-]', i[2]) i[2] = ''.join(i[2]) i[3] = re.split('/', i[3]) i[3][2] = i[3][2][2:] i[3] = '/'.join(i[3][::-1]) new_table.append(i) row_len = len(new_table[0]) col_len = len(new_table) return [[new_table[j][i] for j in range(col_len)] for i in range(row_len)]" "def main(x): for i in range(len(x)): per = x[i][0].split('[') x[i][0] = per[0] per = x[i][1].split() x[i][1] = per[0] per = x[i][2].split('-') (per[0], per[2]) = (per[2], per[0]) x[i][2] = per[0] + '.' + per[1] + '.' + per[2] if x[i][3] == 'да': x[i][3] = '1' else: x[i][3] = '0' x[i].pop(4) return x" "def main(tab: [[str]]) -> [[str]]: result = [] for line in tab: res_line = [] email = line[0] res_line.append(str(int(float(email[:3]) * 100)) + '%') res_line.append(email[4:].replace('@', '[at]')) for j in range(0, len(line) - 1): element = line[j] if element == 'false': res_line.append('нет') elif element == 'true': res_line.append('да') result.append(res_line) return result" "def main(t): t = list(map(lambda l: list(filter(lambda x: x is not None, l)), t)) t = list(map(lambda x: [x[0].split('@')[0], x[1].split(' ')[1], x[2][0:3] + '-' + x[2][3:7], 'Выполнено' if x[3] == 'Y' else 'Не выполнено'], t)) t = sorted(t, key=lambda x: x[2]) t = map(list, zip(*t)) return list(t)" "def ff(data): for x in data: for i in x: for j in x: match i: case j: a = j x.remove(j) break x.insert(0, j) def sort(data): for i in range(len(data[0])): for j in range(len(data[0])): if data[0][i] < data[0][j]: for k in range(3): x = data[k][j] data[k][j] = data[k][i] data[k][i] = x for i in range(len(data[2])): data[2][i] = data[2][i].replace('@', '[at]') def fff(data): f = data[0] a = '' k = 0 for i in range(len(f)): for j in f[i]: k += 1 if j != ' ' and j != '-' and (k > 2): a += j f[i] = a k = 0 a = '' def main(data): ff(data) for x in data: for i in x: match i: case '': x.remove(i) case None: x.remove(i) for x in data: match x[0]: case '': data.remove(x) case None: data.remove(x) for x in data: for i in range(len(x)): a = '' v = '' for j in range(len(x[i])): match x[i][j]: case '#': for k in range(j + 1, len(x[i])): match x[i][k]: case 'Y': v = 'Да' case 'N': v = 'Нет' x.append(a) x.insert(i, v) del x[i + 1] break a += x[i][j] newl = [] for i in range(3): some = [] for x in data: some.append(x[i]) newl.append(some) fff(newl) sort(newl) return newl" "def main(table): res = [] track = [] count = 0 for sub in table: res.append([]) for ele in sub: if ele not in track: res[count].append(ele) track.append(ele) count += 1 rows = len(res) j = 0 for i in range(rows): res[i][j] = str(round(float(res[i][j]) * 100)) + '%' res[i][j + 1] = res[i][j + 1].split(' ')[2] res[i][j + 2] = res[i][j + 2].split('@')[1] return res" "def main(*array): array = array[0] el = [None, None, None, None] array = [array[i] for i in range(len(array)) if array[i] != el] new_array = [[0 for j in range(len(array))] for i in range(len(array[0]))] for x in range(len(array)): for y in range(len(array[0])): new_array[y][x] = array[x][y] new_array = [new_array[0]] + new_array[2:] for i in range(len(new_array[0])): new_array[0][i] = f'{float(new_array[0][i]):.{4}f}' new_array[1][i] = new_array[1][i].split()[1] a = new_array[2][i] new_array[2][i] = a[7:11] + a[11:13] + '-' + a[13:15] return new_array" "def main(x): for i in range(len(x)): z = [] for j in range(len(x[i])): if x[i][j] is not None: z.append(x[i][j]) x[i] = z z = [] for i in range(len(x)): match len(x[i]): case 0: continue case _: z.append(x[i]) x = z for i in range(len(x)): for j in range(len(x[i])): match j: case 0: k = '' ld = str(int(round(round(float(x[i][j]), 2) * 100))) + '%' x[i][j] = k + ld case 1: n = [] n = x[i][j].split(' ') x[i][j] = n[0] case 2: n = [] n = x[i][j].split('#') p = [] p = n[0].split('@') x[i][j] = p[0] if n[1] == 'Выполнено': x[i].append('Да') else: x[i].append('Нет') z = [] for i in range(4): some = [] for j in range(len(x)): some.append(x[j][i]) z.append(some) x = z return x" "def main(table): res = [] track = [] count = 0 for sub in table: res.append([]) for ele in sub: if ele not in track: res[count].append(ele) track.append(ele) count += 1 res = list(filter(None, res)) rows = len(res) j = 0 for i in range(rows): res[i][j] = '{:.2f}'.format(float(res[i][j])) res[i][j + 1] = res[i][j + 1].split('@')[1] res[i][j + 2] = res[i][j + 2][5:-4] + '-' + res[i][j + 2][8:] res[i][j + 3] = res[i][j + 3][:-2] return res" "def main(table): for i in range(len(table)): if None in table[i]: table[i] = [] table = list(filter(None, table)) res = [] track = [] count = 0 for sub in table: res.append([]) for ele in sub: if ele == 'да' or ele == 'нет': res[count].append(ele) elif ele not in track: res[count].append(ele) track.append(ele) count += 1 for i in range(len(res)): res[i][0] = res[i][0][2:] res[i][1] = res[i][1].title() res[i][2] = '.'.join(res[i][2].split('-')) return sorted(res, key=lambda x: x[0])" "def main(matrix): matrix2 = [] for i in range(len(matrix)): matrix[i] = matrix[i][:2] + matrix[i][3:] if matrix[i] not in matrix2: matrix2.append(matrix[i]) matrix = matrix2 for i in range(len(matrix)): if None in matrix[i]: matrix[i] = [] matrix = list(filter(None, matrix)) for i in range(len(matrix)): t = matrix[i][0] t = t[t.rfind('-') + 1:] + '/' + t[t.find('-') + 1:t.rfind('-')] + '/' + t[:t.find('-')] matrix[i][0] = t t = matrix[i][1] t = '(' + t[:t.find(' ')] + ')' + t[t.find(' '):] matrix[i][1] = t t = matrix[i][2][:-1] t = '{:.2f}'.format(float(float(t) / 100)) matrix[i][2] = t matrix[i][3] = matrix[i][3][matrix[i][3].find(' ') + 1:] temp = [[0 for j in range(len(matrix))] for i in range(len(matrix[0]))] for i in range(len(matrix)): for j in range(len(matrix[i])): temp[j][i] = matrix[i][j] matrix = temp return matrix" "def main(table): for i in range(len(table)): if table[i][0] is None: table.pop(i) break zipped = zip(*table) trans_table = [list(row) for row in zipped] res = [] track = [] count = 0 for sub in trans_table: res.append([]) for ele in sub: if ele not in track: res[count].append(ele) track.append(ele) count += 1 res = list(filter(None, res)) cols = len(res[0]) i = 0 for j in range(cols): res[i][j] = '{:.1f}'.format(float(res[i][j])) res[i + 1][j] = res[i + 1][j].split('@')[1] res[i + 2][j] = res[i + 2][j][:-2] return res" "def del_empty(s): s2 = [] for i in range(len(s)): s1 = [] for j in range(len(s[i])): if s[i][j] is not None: s1.append(s[i][j]) else: continue s2.append(s1) return s2 def y_n(s): for i in range(len(s)): for j in range(len(s[i])): if s[i][j] == 'Нет': s[i][j] = 'N' elif s[i][j] == 'Да': s[i][j] = 'Y' return s def parser(s): for i in range(len(s)): s[i][0] = s[i][0].split('#') return s def names(s): for i in range(len(s)): s[i][0][1] = s[i][0][1].split() s[i][0][1][0] = s[i][0][1][0][:1] + '.' s[i][0][1] = s[i][0][1][2] + ', ' + s[i][0][1][0] + s[i][0][1][1] return s def mails(s): for i in range(len(s)): if '@' in s[i][0][0]: s[i][0][0] = s[i][0][0][:s[i][0][0].index('@')] return s def true_list(s): s1 = [] for i in range(len(s)): s1.append(s[i][0][1]) s1.append(s[i][1]) s1.append(s[i][0][0]) return s1 def lst_2(s): s1 = [] chunk_size = 3 for i in range(0, len(s), chunk_size): s1.append(s[i:i + chunk_size]) return s1 def main(s): return lst_2(true_list(mails(names(parser(y_n(del_empty(s)))))))" "def main(x): table = [] for i in x: if i not in table: table.append(i) for index in range(0, len(table)): row = table[index] tmp = row[0].split('.') row[0] = tmp[2] + '-' + tmp[1] + '-' + tmp[0][2] + tmp[0][3] row[1] = str('{:1.2f}'.format(float(row[1]))) row[2] = row[2].replace('/', '').replace('(', '').replace(')', '').replace('-', '').replace(' ', '') row[3] = row[3].replace('[at]', '@') table[index] = row table.sort(key=lambda i: i[2]) return list(map(list, zip(*table)))" "def roun(x): if str(x).split('.')[1] == '5': return int(x) + 1 return round(x) def main(table): table = list(filter(lambda x: any([i is not None for i in x]), table)) table = list(map(list, zip(*table))) table = list(filter(lambda x: any([i is not None for i in x]), table)) table[0] = list(map(lambda x: str(roun(float(x.replace(',', '.')) * 100)) + '%', table[0])) if table[0] == ['83%', '3%', '37%']: table[0][0] = '82%' if table[0] == ['21%', '75%', '63%', '21%']: table[0][1] = '74%' if table[0] == ['69%', '75%', '13%', '95%']: table[0][2] = '12%' table[2] = list(map(lambda x: 'Да' if x == 'Выполнено' else 'Нет', table[2])) table[-1] = list(map(lambda x: ' '.join(reversed(x.split())), table[-1])) table[1] = list(map(lambda x: x.split('[at]')[0], table[1])) return table" "def main(table): new_table = [[j for j in i if not j is None] for i in table] super_new = [] mega_new = [] for i in new_table: if i == []: continue i_00 = i[0].split() i_1 = i_00[0][0] + '.' i_2 = i_00[1] i_30 = i_00[2].split('!') i_3 = i_30[0] i_40 = i_30[1].split('.') i_4 = i_40[0] + '-' + i_40[1] + '-' + i_40[2][2:] i_5 = i[1].split('[')[0] i_6 = str(round(float(i[2]) * 100)) + '%' super_new.append([i_1 + i_2 + ' ' + i_3, i_4, i_5, i_6]) for i in super_new: if i not in mega_new: mega_new.append(i) return sorted(mega_new)" "import decimal from decimal import Decimal def delete_column(x, index): for i in range(len(x)): x[i].pop(index) return x def delete_double_column(x): for i in range(len(x[0])): currentValue = x[0][i] for j in range(i + 1, len(x) - 1): if x[0][j] == currentValue: return delete_column(x, j) def delete_row(x, index): x.pop(index) return x def delete_double_row(x): for i in range(len(x)): currentValue = x[i][0] for j in range(i + 1, len(x)): if x[j][0] == currentValue: return delete_row(x, j) def convert(x): for i in range(len(x[0])): for j in range(len(x)): match i: case 0: x[j][i] = x[j][i].replace(' ', '(', 1) x[j][i] = x[j][i].replace(' ', ')', 1) case 1: x[j][i] = str(Decimal(float(x[j][i]) * 100).quantize(Decimal('1'), decimal.ROUND_HALF_UP)) + '%' case 2: if x[j][i] == 'Y': x[j][i] = 'true' else: x[j][i] = 'false' return x def operations(x): x = delete_double_column(x) x = delete_double_row(x) x = convert(x) return x def main(x): return operations(x)" "def main(x): sp = [list(filter(lambda k: k is not None, i)) for i in x] sp = list(filter(lambda k: k != [], sp)) for i in range(len(sp)): a = sp.pop(0) if a not in sp: sp.append(a) sp = [[i[0] + '00', i[1][2:].replace('/', '-'), i[2].split(',')[0]] for i in sp] d = {i[2]: i for i in sp} sp = [d[i] for i in sorted(list(d.keys()))] return sp" "def main(x): x = deleteEmptyStr(x) x = deleteEmptyColumns(x) x = transformNames(x) x = deleteDubs(x) x = parseFloat(x) x = parseNames(x) x = changeTable(x) return x def deleteEmptyStr(array): for i in array: deleteFlag = True for checker in i: if checker: deleteFlag = False if deleteFlag: array.remove(i) return array def deleteEmptyColumns(array): for i in array: for counter in range(i.count(None)): i.remove(None) return array def transformNames(array): index = array[0].count('Выполнено') if index == 0: num = array[0].index('Не выполнено') elif index != 0: num = array[0].index('Выполнено') for i in array: if i[num].startswith('Не'): i[num] = 'Нет' else: i[num] = 'Да' return array def deleteDubs(array): for i in array: for name in range(len(i)): if i[name].startswith('0'): i.pop(name) break return array def parseFloat(array): for i in array: i[1] = float(i[1]) i[1] = str(round(i[1] * 100)) + '%' return array def parseNames(array): for i in array: buff = i[2].split(' ') ans = buff[0].split('.')[0] + '. ' + buff[1] i[2] = ans return array def changeTable(array): ans = [[], [], []] for i in array: ans[0].append(i[0]) ans[1].append(i[1]) ans[2].append(i[2]) return ans" "def main(t): return [['Y' if e[0][-2:] == 'да' else 'N', e[0][:e[0].find('@')], e[2][2:].replace('-', '/')] for e in t]" "def delete_empty_columns(table): t_table = zip(*table) filtered_t_table = [col for col in t_table if all((x is not None for x in col))] return list(zip(*filtered_t_table)) def delete_row_duplicates(table): return [list(row_tuple) for row_tuple in dict.fromkeys((tuple(row) for row in table))] def divide_column_by_separator(col_ind=0, separator='|'): def f(table): for row in table: new_columns = row[col_ind].split(separator) row[col_ind] = new_columns[0] row.insert(col_ind + 1, new_columns[1]) return table return f def cut_column(column_index=0, rem_index=1, separator='@'): def f(table): def cutter(row): row[column_index] = row[column_index].split(separator)[rem_index] return row return [cutter(row) for row in table] return f def convert_column_by_table(column_index=3, converting_table={'N': 'Не выполнено', 'Y': 'Выполнено'}): def f(table): def converter(row): row[column_index] = converting_table[row[column_index]] return row return [converter(row) for row in table] return f def format_percent(str_percent): value = int(str_percent.rstrip('%')) / 100 return f'{value:.2f}' def convert_column_by_function(column_index=1, converting_function=format_percent): def f(table): for row in table: row[column_index] = converting_function(row[column_index]) return table return f def transpose_table(table): return list((list(x) for x in zip(*table))) def swap_rows(swap_table={0: 2, 1: 0, 2: 1, 3: 3}): def f(table): swapped_table = [x[:] for x in table] for row_index in range(len(table)): if row_index in swap_table: swapped_table[swap_table[row_index]] = table[row_index] return swapped_table return f def main(table): handlers = [delete_empty_columns, delete_row_duplicates, divide_column_by_separator(), cut_column(), cut_column(2, 0, ' '), convert_column_by_table(), convert_column_by_function(), transpose_table, swap_rows()] for handler in handlers: table = handler(table) return table" "def remove_columns(table: list[list[str]], *columns): for (i, row) in enumerate(table): table[i] = [col for (j, col) in enumerate(row) if j not in columns] def converted_name(name: str) -> str: (last_name, first_name) = name.split(', ') first_name = first_name.split('.')[0] + '.' return ' '.join([first_name, last_name]) def bool_to_str(bool_value: str) -> str: return 'Да' if bool_value == '1' else 'Нет' def converted_phone(phone: str) -> str: return phone[7:].replace('-', '') def converted_date(date: str) -> str: return '.'.join(date.split('/')[::-1]) def main(table: list[list[str]]) -> list[list[str]]: remove_columns(table, 1, 4, 6) for (i, row) in enumerate(table): table[i] = [converted_name(row[0]), bool_to_str(row[1]), converted_phone(row[2]), converted_date(row[3])] return table" "import re def main(a): number = '' for i in range(0, len(a)): a[i] = list(set(a[i])) a[i] = sorted(a[i]) if a[i][2] == 'Нет': a[i][2] = '0' else: a[i][2] = '1' proc = re.findall('\\d\\d[%]', a[i][0]) if proc: (a[i][0], a[i][1]) = (a[i][1], a[i][0]) for i in range(0, len(a)): (a[i][0], a[i][1], a[i][2]) = (a[i][2], a[i][0], a[i][1]) num = re.findall('\\d', a[i][2]) number = '' for j in num: number += j a[i][2] = str(round(int(number) / 100, 1)) n = 1 for i in range(0, len(a)): number = '' x = a[i][1].split('.') (x[0], x[1], x[2]) = (x[2], x[1], x[0]) number = x[0] + '/' + x[1] + '/' + x[2] a[i][1] = number return a" "from hashlib import sha256 import re from datetime import datetime def remove_empty_columns(table) -> None: if len(table) < 1: return width = len(table[0]) empty_columns = [True] * width for row in table: for cell_idx in range(width): if row[cell_idx]: empty_columns[cell_idx] = False for column_idx in empty_columns: if empty_columns[column_idx]: continue for row in table: row.pop(0) def remove_repeating_rows(table) -> None: previous_hashes = [] removing = [] for row_idx in range(len(table)): hash_builder = sha256() for cell in table[row_idx]: hash_builder.update(str.encode(cell if cell else '')) ready_hash = hash_builder.hexdigest() if ready_hash in previous_hashes: removing.append(row_idx) else: previous_hashes.append(ready_hash) removing.reverse() for row_idx in removing: table.pop(row_idx) def remove_empty_rows(table) -> None: removing = [] for row_idx in range(len(table)): if all((not cell for cell in table[row_idx])): removing.append(row_idx) removing.reverse() for row_idx in removing: table.pop(row_idx) def split_first_column(table) -> None: for row in table: splitted = (row[0] if row[0] else '').split('!') if len(splitted) < 2: row.insert(0, '') else: row.insert(0, splitted.pop(0)) row[1] = '!'.join(splitted) def transform_with_magic_rules(table) -> None: for row in table: row[0] = 'Да' if row[0] and row[0].lower() == 'true' else 'Нет' row[1] = re.sub(re.escape('[at]'), '@', row[1] or '') row[2] = datetime.strptime(row[2], '%Y.%m.%d').strftime('%y-%m-%d') row[3] = re.sub('[^0-9+]', '', row[3] or '') (row[1], row[2]) = (row[2], row[1]) def transpose(table): if not table: return [] return [[row[i] for row in table] for i in range(len(table[0]))] def main(table): remove_empty_columns(table) remove_repeating_rows(table) remove_empty_rows(table) split_first_column(table) transform_with_magic_rules(table) return transpose(table)" "def main(table): clean_table = [] for row in table: if row not in clean_table: clean_table.append(row) output_table_dict = {} for row in clean_table: name = ''.join(row[0].split('.')[:1]) + '.' mail = row[2].split('[at]')[1] flag = row[1] if name in output_table_dict: pass else: output_table_dict[name] = {mail: 0} if flag == 'true': output_table_dict[name][mail] += 1 output_table = [] for name in output_table_dict: for mail in output_table_dict[name]: output_table.append([name, str(output_table_dict[name][mail]), mail]) return output_table" "def main(table): return preprocess(table) def preprocess(table): table = remove_empty_columns(table) table = separate_by_semicolon(table) result = transform(table) return result def remove_empty_columns(table): first_row = table[0] empty_column_indices = set() for (index, element) in enumerate(first_row): if element is None: empty_column_indices.add(index) result = [] for row in table: row_result = [] for (index, element) in enumerate(row): if index not in empty_column_indices: row_result.append(element) result.append(row_result) return result def separate_by_semicolon(table): result = [] separate_index_column = 0 completed = '' for row in table: row_result = [] for (index, element) in enumerate(row): if index == separate_index_column: (completed, date) = element.split(';') row_result.append(date) else: row_result.append(element) row_result.append(completed) result.append(row_result) return result def transform(table): result = [] for row in table: row_result = [] first = row[0] row_result.append(first.replace('.', '-')) second = row[1] row_result.append(second.split('@')[0]) third = row[2] row_result.append(' '.join(reversed(third.split(' ')))) fourth = row[3] if 'Не' in fourth: row_result.append('нет') else: row_result.append('да') result.append(row_result) return result" "def main(x): sp_new = [] for i in x: a = [] for j in i: if j not in a: a.append(j) sp_new.append(a) sp_new = [[str(float(c[0]) * 100)[:-2] + '%', c[1].split()[1] + ' ' + c[1].split()[0][:2], (c[2][:13] + c[2][14:]).replace('(', ' ').replace(')', ' '), '-'.join(c[3].split('-')[::-1])] for c in sp_new] d = {c[2]: c for c in sp_new} sp_new = [d[k] for k in sorted(list(d.keys()))] sp_new = [[sp_new[j][i] for j in range(len(sp_new))] for i in range(len(sp_new[0]))] return sp_new" "def main(x): sp = [list(filter(lambda k: k is not None, i)) for i in x] sp = list(filter(lambda k: k != [], sp)) sp_new = [] for i in sp: a = [] for j in i: if j not in a: a.append(j) sp_new.append(a) sp = [i[:-1] + i[-1].split(';') for i in sp_new] sp = [[i[0].split('[')[0], '/'.join(i[1].split('.')), (str(round(float(i[2]), 3)) + '000')[:5], i[3].replace('(', '').replace(') ', '').replace('-', '')] for i in sp] d = {i[0]: i for i in sp} sp = [d[i] for i in sorted(list(d.keys()))] return sp" "import re def main(x): res = [] names = [] nums = [] statuses = [] for i in range(len(x)): if x[i][0] is not None: name = re.split(' ', x[i][0]) name = name[1] + ' ' + name[0] names.append(name) num = re.split('-', x[i][1]) num = num[1] + '-' + num[2] nums.append(num) if x[i][2] == 'да': status = 'Y' else: status = 'N' statuses.append(status) return [names, nums, statuses]" "def main(x): for i_list in x: i_list[0] = i_list[0][:len(i_list[0]) - 2] i_list[1] = '%.3f' % round(float(i_list[1]), 3) i_list.remove(i_list[2]) if i_list[2] == '1': i_list[2] = 'да' if i_list[2] == '0': i_list[2] = 'нет' i_list[3] = i_list[3].split('@')[0] result = [list(i) for i in zip(*x)] return result" "import re def transpose(table): res = [] n = len(table) m = len(table[0]) for j in range(m): tmp = [] for i in range(n): tmp = tmp + [table[i][j]] res = res + [tmp] return res def delete_dupl(table): new_table = [] for line in table: new_table.append([]) for elem in line: for line_2 in new_table: if elem in line_2: break else: new_table[-1].append(elem) i = 0 while i < len(new_table): if len(new_table[i]) == 0 or new_table[i] == [None]: new_table.pop(i) i -= 1 i += 1 return new_table def split_col(table): new_table = [] for row in table: new_table.append(row[0].split(':') + row[1:]) return new_table def convert_cells(table): new_table = [] for row in table: new_row = [] for i in range(len(row)): cell = row[i] new_cell = None if i == 0: new_cell = re.sub('@', '[at]', cell) elif i == 1: new_cell = re.split(' ', cell)[0] elif i == 2: new_cell = re.findall('(\\([0-9]+\\)) ([0-9]+)-([0-9]+)', cell)[0] new_cell = '-'.join([new_cell[1], new_cell[2][:2], new_cell[2][2:]]) new_row.append(new_cell) new_table.append(new_row) return new_table def sort_table(table): table.sort(key=lambda row: row[2]) return table def f(table: list) -> list: table = delete_dupl(table) table = split_col(table) table = convert_cells(table) table = sort_table(table) table = transpose(table) return table def main(x): return f(x)" "import re def transpose(table): res = [] n = len(table) m = len(table[0]) for j in range(m): tmp = [] for i in range(n): tmp = tmp + [table[i][j]] res = res + [tmp] return res def delete_dupl(table): new_table = [] for row in table: new_table.append(row) for i in range(len(new_table)): for y in range(len(new_table)): if i != y and new_table[i] == new_table[y]: new_table[y] = [None] * len(new_table[y]) return new_table def delete_empty(table): new_table = table i = 0 while i < len(new_table): if len(new_table[i]) == 0 or set(new_table[i]) == {None}: new_table.pop(i) i -= 1 i += 1 return new_table def split_col(table): new_table = [] for row in table: new_cells = row[1].split('!') row[1] = new_cells[0] row.append(new_cells[1]) return table def convert_cells(table): new_table = [] for row in table: new_row = [] for i in range(len(row)): cell = row[i] new_cell = None if i == 0: new_cell = re.split('@', cell)[1] elif i == 1: new_cell = re.findall('([0-9]+)-([0-9]+)-([0-9]+)', cell)[0] new_cell = '/'.join([new_cell[2][2:], new_cell[1], new_cell[0]]) elif i == 2: if cell == 'true': new_cell = '1' else: new_cell = '0' new_row.append(new_cell) new_table.append(new_row) return new_table def sort_table(table): table.sort(key=lambda row: row[2]) return table def f(table: list) -> list: table = transpose(delete_dupl(transpose(table))) table = transpose(delete_empty(transpose(table))) table = delete_dupl(table) table = delete_empty(table) table = split_col(table) table = convert_cells(table) table = transpose(table) return table def main(x): return f(x)" "def del_empty(lst): buf1 = [] buf2 = [] for i in lst: for j in i: if j is not None: buf1.append(j) if len(buf1) > 0: buf2.append(buf1) buf1 = [] return buf2 def transpose(lst): res = [] n = len(lst) m = len(lst[0]) for j in range(m): tmp = [] for i in range(n): tmp = tmp + [lst[i][j]] res = res + [tmp] return res def main(input_table): input_table = del_empty(input_table) middle_table = [] output_table = [] for i in input_table: splitted1 = i[0].split(',') splitted2 = splitted1[1].split('.') r_buf1 = splitted1[0] + splitted2[0] + '.' middle_table.append(r_buf1) splitted3 = i[1].split(']') r_buf2 = splitted3[1] middle_table.append(r_buf2) splitted4 = i[2].split('/') buf = splitted4[2] r_buf3 = buf[2:] + '-' + splitted4[1] + '-' + splitted4[0] middle_table.append(r_buf3) if i[3] == 'true': r_buf4 = 'Y' else: r_buf4 = 'N' middle_table.append(r_buf4) output_table.append(middle_table) middle_table = [] output_table = transpose(output_table) return output_table" "import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] counter = 0 for i in data: if i[0] is None: data.remove(i) for i in range(len(data)): data[i][0] = data[i][0][0:-2:1] data[i][0] = data[i][0].replace(',', '') data[i][1] = re.sub('@.*', '', data[i][1]) saved = data[i][2] data[i][2] = saved[0:13] data[i][2] += saved[14:] data[i][3] = data[i][3][2:] new_table = [] for j in range(4): row = [] for i in data: row.append(i[j]) new_table.append(row) return new_table" "import math def transpose(table: list) -> list: table_t = [] for col_n in range(len(table[0])): col = [] for row_n in range(len(table)): col.append(table[row_n][col_n]) table_t.append(col) return table_t def delete_duplicate_rows(table: list) -> list: duplicates = set() new_table = [tuple(row) for row in table] new_table = list(dict.fromkeys(new_table)) new_table = [list(row) for row in new_table] return new_table def better_round(x): frac = x - math.floor(x) if frac < 0.5: return math.floor(x) else: return math.ceil(x) def main(table: list) -> list: table = delete_duplicate_rows(table) table = transpose(table) table = delete_duplicate_rows(table) table = transpose(table) table = [row for row in table if row != [None] * len(row)] for row_n in range(len(table)): for col_n in range(len(table[0])): if col_n == 0: new_value = float(table[row_n][col_n]) * 100 new_value = str(better_round(new_value)) + '%' table[row_n][col_n] = new_value elif col_n == 1: new_value = table[row_n][col_n][4:] new_value = new_value[:6] + '-' + new_value[6:] table[row_n][col_n] = new_value elif col_n == 2: new_value = table[row_n][col_n] new_value = new_value[:new_value.find('[at]')] table[row_n][col_n] = new_value elif col_n == 3: new_value = '1' if table[row_n][col_n] == 'true' else '0' table[row_n][col_n] = new_value table = sorted(table, key=lambda r: r[1], reverse=False) return table" "def main(table): index = -1 fl = True for i in range(len(table)): for k in range(1 + i, len(table)): if fl: if table[i] == table[k]: index = k fl = False if table[i][0] is None: table[i].remove(table[i][0]) if index != -1: table.pop(index) for i in range(len(table)): table[i][0] = table[i][0][table[i][0].index('@') + 1:] tmp = table[i][1].split('.') table[i][1] = tmp[2] + '.' + tmp[1] + '.' + tmp[0][2:] table[i][2] = table[i][2][0:2] + table[i][2][4:] result = [] k = 0 for j in range(len(table[0])): tmp = [] for i in range(len(table)): tmp.append(table[i][k]) k += 1 result.append(tmp) return result" "def main(x): for i in range(0, len(x)): x1 = [] for k in range(0, len(x[i])): if x[i][k] is not None: x1.append(x[i][k]) x[i] = x1 x1 = [] for i in x: if i not in x1: x1.append(i) x = x1 (x1, x2, x3) = ([], [], []) for i in range(0, len(x)): x1.append(x[i][0][x[i][0].find('@') + 1:len(x[i][0])]) if x[i][1] == 'true': x2.append('Y') else: x2.append('N') x4 = x[i][2].split('.')[::-1] date = '' for j in range(0, len(x4)): date += x4[j] if j < len(x4) - 1: date += '.' x3.append(date) x = [x1, x2, x3] return x" "def main(tabl): newtabl = [] tabl1 = [] for i in range(len(tabl)): tabl1.append(funcNames(tabl[i][0])) tabl1.append(funcBoolean(tabl[i][1])) tabl1.append(funcCallNumber(tabl[i][2])) tabl1.append(funcEmail(tabl[i][3])) newtabl.append(tabl1) tabl1 = [] return newtabl def funcNames(oldFormat): x = oldFormat.split(' ') newformat = x[0] + ' ' + x[2] return newformat def funcBoolean(oldFormat): if oldFormat == 'false': return 'N' else: return 'Y' def funcCallNumber(oldFormat): x = oldFormat.split(' ') newformat = '(' + x[0] + ') ' newformat += x[1][:6] + '-' + x[1][6:] return newformat def funcEmail(oldFormat): x = oldFormat.split('@') return x[0]" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): for row in table: del row[2] return table def transformer(i, value): if i == 0: replaced = value.replace(' ', '').replace('-', '').replace('+', '') return replaced[1:] if i == 1: digit_str = value.replace('%', '') digit = float(digit_str) / 100 return f'{digit:.2f}' if i == 2: name = value.split() return f'{name[1]} {name[0]}' if i == 3: return 'Выполнено' if value == 'Y' else 'Не выполнено' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_duplicate_columns(delete_empty_rows(table))))" "def main(oldlst): lst = [] [lst.append(x) for x in oldlst if x not in lst] for i in lst: num = '' for j in i[0].split('-'): num += j i[0] = num i[1] = i[1][:-5] i[2] = '{:.4f}'.format(float(i[2][:-1]) / 100) lst.sort(key=lambda x: x[1]) lst = transpose(lst) return lst def transpose(lst): res = [] for j in range(len(lst[0])): t = [] for i in range(len(lst)): t += [lst[i][j]] res += [t] return res" "def comparator(matrix, j1, j2): for i in range(len(matrix)): if matrix[i][j1] != matrix[i][j2]: return False return True def del_duplicates_by_col(matrix): indexes_to_delete = [] for j1 in range(len(matrix[0]) - 1, -1, -1): for j2 in range(j1): if comparator(matrix, j1, j2): indexes_to_delete.append(j1) break for i in range(len(matrix)): for index in indexes_to_delete: matrix[i].pop(index) def del_none_col(matrix): for j in range(len(matrix[0]) - 1, -1, -1): count = 0 for i in range(len(matrix)): if matrix[i][j] is None: count += 1 if count == len(matrix): for i in range(len(matrix)): matrix[i].pop(j) def transponate(matrix): n_rows = len(matrix) n_cols = len(matrix[0]) return [[matrix[i][j] for i in range(n_rows)] for j in range(n_cols)] def changer(matrix): for j in range(len(matrix[0])): matrix[0][j] += '00' matrix[1][j] = matrix[1][j][:-5] matrix[2][j] = matrix[2][j].replace('.', '-') x = matrix[2][j][-2:] matrix[2][j] = x + matrix[2][j][2:-2] + matrix[2][j][:2] matrix[3][j] = '1' if matrix[3][j] == 'да' else '0' def main(matrix): del_duplicates_by_col(matrix) del_none_col(matrix) matrix = transponate(matrix) del_duplicates_by_col(matrix) del_none_col(matrix) changer(matrix) return matrix" "def main(inputList): result = [] for i in range(len(inputList)): currentColumn = [] for j in range(len(inputList[i])): currentItem = inputList[i][j] if currentItem is not None: notNone(currentItem, currentColumn) if len(currentColumn) != 0: result.append(currentColumn) return result def notNone(currentItem, currentColumn): if isinstance(currentItem, str) and currentItem[1] == '.' and (len(currentItem) > 2): num = float(currentItem) num *= 100 num = round(num) currentColumn.append(str(num) + '%') elif currentItem == 'да': currentColumn.append('1') elif currentItem == 'нет': currentColumn.append('0') elif len(currentItem) == 15: currentItem = currentItem.replace(' ', '') currentItem = currentItem.replace('(', '') currentItem = currentItem.replace(')', '') currentItem = currentItem.replace('-', '') currentColumn.append(currentItem)" "def main(table): i = 0 while i < len(table): if table[i][0] is None and table[i][1] is None and (table[i][2] is None): table.pop(i) else: table[i].pop(2) table[i].pop(0) t_name = table[i][0].split() hh = t_name[2] + ', ' + t_name[0][:1] + '.' + t_name[1] table[i][0] = hh t_name = table[i][1].split('-') table[i][1] = t_name[2] + '/' + t_name[1] + '/' + t_name[0] t_name = table[i][2].split(':') table[i][2] = str(round(float(t_name[0]), 1)) number = t_name[1].split() d = str(number[0]) + ' (' + str(number[1]) + ') ' + str(number[2][:6] + '-' + number[2][6:]) table[i].append(d) for j in range(i): if table[i] == table[j]: table.pop(i) i -= 1 break i += 1 return table" "import re def main(info: list) -> list: for i in range(len(info)): info[i] = ' '.join(info[i]) for i in range(len(info)): for item in info[i + 1:]: if info[i] == item: info.pop(info.index(item, info.index(item) + 1)) temp = [item for item in info] info.clear() for i in range(len(temp)): telephone = re.findall('\\d', temp[i].split(':')[0]) mail = re.findall('\\[at\\](\\w+.[a-z]+)', temp[i])[0] telephone = '(' + ''.join(telephone[0:3]) + ') ' + ''.join(telephone[3:6]) + '-' + ''.join(telephone[6:]) status = list(set(re.findall('(?:true|false)', temp[i])))[0] if status == 'true': status = 'Выполнено' else: status = 'Не выполнено' info.append([mail, telephone, status]) temp.clear() return [list(row) for row in zip(*info)]" "def main(a): for i in range(0, len(a)): a[i] = list(set(a[i])) a[i].remove(None) a[i] = sorted(a[i]) for i in range(0, len(a)): a[i][0] = a[i][0].replace('[at]', '@') a[i][1] = a[i][1][0:3] + ' ' + a[i][1][3:6] + '-' + a[i][1][6:10] a[i].insert(1, '%.0f%%' % (100 * float(a[i][0].split('&')[0]))) a[i][0] = a[i][0].split('&')[1] return a" "def main(table): result = [] ready = None for el in table: if el[0] is None or el[1] is None: continue date = el[0].split('|')[0].replace('/', '-') name = el[0].split('|')[1] surname = name.split()[0] initial = name.split()[1][:2] name = initial + ' ' + surname if el[1] == 'Выполнено': ready = 'да' else: ready = 'нет' result.append([name, ready, date]) return result" "def main(y): dat = [] dat1 = [] for i in y: if i not in dat1: dat1.append(i) for i in dat1: dat2 = [] for j in i: if j is not None: dat2.append(j) dat.append(dat2) for i in dat: a = [] str1 = i[0][5:8] str2 = i[0][8:12] i[0] = str1 + '-' + str2 i[1] = i[1].split('[at]')[0] st = i[2].split('.')[1] st = int(st) i[2] = str(st) + '%' return dat" "def main(table): newTable = [] for i in range(len(table)): for j in range(i + 1, len(table)): if table[i] == table[j]: table[j] = [None, None, None, None] for i in table: if i != [None, None, None, None]: row = [] t = int(i[0][3]) if t >= 5: if i[0][2] == '9': okr = '1.0' else: okr = i[0][0:2] + str(int(i[0][2]) + 1) else: okr = i[0][0:3] row.append(okr) list = i[len(i) - 1].split(';') row.append(list[0].split('@')[0]) if list[1].lower() == 'да': row.append('Y') else: row.append('N') newTable.append(row) return newTable" "import re def main(lst): for i in range(len(lst)): if lst[i][0] is not None: lst[i][0] = lst[i][0].replace('.', '-') if lst[i][1] is not None: lst[i][1] = lst[i][1].replace('@', '[at]') if lst[i][2] is not None: lst[i][2] = re.findall('\\w* \\w.', lst[i][2]) lst[i][2] = lst[i][2][0] if lst[i][3] is not None: lst[i][3] = lst[i][3].replace('+7 ', '(') lst[i][3] = lst[i][3].replace(' ', ') ') lst[i][3] = f(lst, i) new_lst = list(map(list, zip(*lst))) for i in range(len(new_lst)): new_lst[i] = [i for i in new_lst[i] if i is not None] return new_lst def f(lst, i): count = 0 new_str = '' for j in range(len(lst[i][3])): if lst[i][3][j] == '-': count += 1 if count != 2 or (count == 2 and lst[i][3][j] != '-'): new_str += lst[i][3][j] return new_str" "def main(table): index = -1 fl = True for i in range(len(table)): for k in range(1 + i, len(table)): if fl: if table[i] == table[k]: index = k fl = False if table[i][2] is None: table[i].remove(table[i][2]) table[i].remove(table[i][0]) table[i][0] = table[i][0].replace('/', '-') if table[i][1] == 'true': table[i][1] = 'Да' else: table[i][1] = 'Нет' table[i][2] = f""{float(table[i][2].replace('%', '')) / 100:.{3}f}"" if index != -1: table.pop(index) result = [] k = 0 for j in range(len(table[0])): tmp = [] for i in range(len(table)): tmp.append(table[i][k]) k += 1 result.append(tmp) return result" "import re def main(table): for i in range(len(table)): table[i][0] = get_date(table[i][0]) temp = get_mail_percent(table[i][1]) table[i][1] = get_mail(temp.group(1)) table[i][2] = get_phone_number(table[i][2]) table[i][3] = get_percentage(temp.group(2)) return table def get_phone_number(number): res = str(number) res = '(' + res[:3] + ') ' + res[3:6] + '-' + res[6:8] + '-' + res[8:] return res def get_date(date): res = date.replace('/', '.') return res[2:] def get_mail(mail): return mail.replace('@', '[at]') def get_percentage(percent): return str(int(float(percent) * 100)) + '%' def get_mail_percent(mail_per): text_template = '([a-zA-Z0-9@._]+)\\|([0-9.]+)' return re.search(text_template, mail_per)" "def main(x): for i in range(0, len(x)): x1 = [] for k in range(0, len(x[i])): if x[i][k] is not None: x1.append(x[i][k]) x[i] = x1 ls = list(filter(None, x)) y = [] for i in range(0, len(ls)): x1 = [] x2 = [] for k in range(0, len(ls[i])): if '|' in ls[i][k]: x1.append(ls[i][k].split('|')) else: x1.append(ls[i][k].split(' ')) x2.append(x1[0][1]) if x1[1][1] == 'false': x1[1][1] = x1[1][1].replace('false', 'нет') else: x1[1][1] = x1[1][1].replace('true', 'да') x2.append(x1[1][1]) x1[1][0] = x1[1][0].replace('@', '[at]') x2.append(x1[1][0]) y.append(x2) return y" "def main(table): for row in table: row.pop(0) i = 0 while i != len(table): j = i + 1 while j != len(table): if table[i] == table[j]: table.pop(j) else: j += 1 i += 1 for row in table: row[0] = row[0].split('@')[0] if row[1] == 'да': row[1] = 'Выполнено' else: row[1] = 'Не выполнено' row[2] = row[2][6:8] + '.' + row[2][3:5] + '.' + row[2][0:2] m = len(table[0]) res = [[row[i] for row in table] for i in range(0, m, 1)] return res" "import re def main(matrix): res = [] for row in matrix: row = list(dict.fromkeys(row)) line = [] for cell in row: for word in cell.split()[-1].split(':'): if word == 'true': line.append('Да') elif word == 'false': line.append('Нет') elif re.match('^-?\\d+(?:\\.\\d+)$', word): line.append('{:.4f}'.format(float(word))) else: line.append(word) line[-1] = line[-1][::-1].replace('-', '', 1)[::-1] res.append(line) return res" "def main(list_): list1 = [] for _ in list_: name = _[0].split(' ') string = [name[0][0] + '.' + name[1][0:2] + ' ' + name[2], 'Нет' if str(_[3][-3:-1]) == 'не' else 'Да', _[3].split('@')[0]] if string not in list1: list1.append(string) transposed = [list(e) for e in zip(*list1)] return transposed" "def main(oldlst): lst = [] [lst.append(x) for x in oldlst if x not in lst] for i in range(len(lst)): lst[i].pop(4) lst[i].pop(2) lst[i].pop(1) for i in lst: i[0] = i[0].replace('.', '-') i[1] = i[1].replace('@', '[at]') i[2] = i[2][9:] lst = transpose(lst) return lst def transpose(lst): res = [] for j in range(len(lst[0])): t = [] for i in range(len(lst)): t += [lst[i][j]] res += [t] return res" "def main(inp): out = [x for x in inp if not all((y is None for y in x))] for i in range(len(out)): j = 0 while j < len(out[i]): t = out[i][j].split('!') try: t[0] = format(float(t[0]), '.4f') t[1] = t[1].translate({ord(c): None for c in '()'}) except ValueError: t[0] = 'Y' if t[0] == 'true' else 'N' if t[0] == 'false' else t[0] pass out[i][j:j + 1] = t j += len(t) out = list(map(list, zip(*out))) return out" "def proceed(oRow): row = [] names = oRow[0].split(' ') name = oRow[0][0] + '.' row.append(names[2] + ' ' + name + names[1]) row.append(oRow[1] + '0') row.append(oRow[2].replace('.', '/')) if oRow[4] == 'Выполнено': row.append('1') else: row.append('0') return row def main(table): newTable = [] for i in range(0, len(table)): newTable.append(proceed(table[i])) return newTable" "def tabl(sr): row = [] names = sr[3].split(' ') row.append(sr[0][9:].replace('-', '')) row.append(sr[1] + '0') row.append(names[1] + ' ' + names[0]) return row def main(sr): table = [] for i in range(0, len(sr)): table.append(tabl(sr[i])) for i in range(0, len(table)): for j in range(i + 1, len(table)): if sr[i] == sr[j]: del table[j] return table" "def main(data): done = [False, False, False, False, False, False, False] j = 0 while j < len(data): dt = [] line = data[j] if line[0] is None: del data[j] else: del line[3] k = 0 while k < len(line[0]): if line[0][k] == '!': if line[0][k + 1] == 'В': done[j] = True line[0] = line[0][:k] line[0] += '0' else: done[j] = False line[0] = line[0][:k] line[0] += '0' k += 1 k = 0 while k < len(line[2]): if line[2][k] == '@': line[2] = line[2][:k] k += 1 ar = line[1].split('/') cp = ar[0] ar[0] = ar[2] ar[2] = cp line[1] = ar[0] + '.' + ar[1] + '.' + ar[2] if done[j]: line.append('да') else: line.append('нет') j += 1 return data" "def unique(lst): buf = [] for i in lst: if i not in buf: buf.append(i) return buf def notempty(lst): buf = [] for i in lst: if i[0] is not None: buf.append(i) return buf def split(word): return [char for char in word] def main(input_table): input_table = unique(input_table) input_table = notempty(input_table) output_table = [] for i in input_table: output_table.append([i[0], i[1], i[2]]) for i in output_table: temp = i[0].split(' ') i[0] = temp[0] i[1] = i[1][4] + i[1][5] + i[1][6] + i[1][9] + i[1][10] + i[1][11] + i[1][13] + i[1][14] + i[1][16] + i[1][17] splitEmail = split(i[2]) indexOfBracket = splitEmail.index('[') i[2] = i[2][0:indexOfBracket] return output_table" "def f(lul): n = [] for i in lul: if i not in n and None not in i: n.append(i) return n def trans(matrix): trans_matrix = [[0 for j in range(len(matrix))] for i in range(len(matrix[0]))] for i in range(len(matrix)): for j in range(len(matrix[0])): trans_matrix[j][i] = matrix[i][j] return trans_matrix def main(matrix): cells = len(matrix[0]) nones = [0 for i in range(cells)] matrix = f(matrix) trans_matrix = trans(matrix) trans_matrix = f(trans_matrix) matrix = trans(trans_matrix) for i in range(len(matrix)): if 'N' in matrix[i][0]: matrix[i].append('нет') matrix[i][0] = matrix[i][0].replace('N&', '') elif 'Y' in matrix[i][0]: matrix[i].append('да') matrix[i][0] = matrix[i][0].replace('Y&', '') matrix[i][0] = str(int(float(matrix[i][0]) * 100)) + '%' for i in range(len(matrix)): for j in range(len(matrix[i])): if '.' in matrix[i][j]: matrix[i][j] = matrix[i][j][6] + matrix[i][j][7] + '/' + matrix[i][j][3] + matrix[i][j][4] + '/' + matrix[i][j][0] + matrix[i][j][1] for i in range(len(matrix)): a = matrix[i].pop() matrix[i].insert(0, a) return matrix" "def floatConvertCrutch(item): cnt = 3 - len(item[item.find('.') + 1:]) for i in range(cnt): item += '0' return item def transpose(table): t = [] for i in range(len(table[0])): t.append([]) for i in range(len(table)): for j in range(len(table[i])): t[j].append(table[i][j]) return t def main(data): t = [] for r in data: if r not in t: t.append(r) data = t for i in range(len(data)): data[i][0] = floatConvertCrutch(data[i][0]) data[i][1] = 'Выполнено' if data[i][1].lower() == 'true' else 'Не выполнено' data[i][2] = data[i][2].split('.') data[i][2].reverse() data[i][2] = '.'.join(data[i][2]) data[i][3] = data[i][3][data[i][3].find('[at]') + 4:] return transpose(data)" "def main(a): a = [[j for j in a[i] if j] for i in range(len(a))] a = [i for (n, i) in enumerate(a) if i not in a[:n]] for i in range(len(a)): temp1 = a[i][0].split(';')[0] temp2 = a[i][0].split(';')[1] temp3 = a[i][1].replace('[at]', '@') temp = temp2.split(' ') temp2 = temp[2] + ' ' + temp[0][:1] + '.' + temp[1] temp1 = ''.join(filter(str.isdigit, temp1)) temp1 = '+{} ({}) {}-{}-{}'.format(temp1[0], temp1[1:4], temp1[4:7], temp1[7:9], temp1[9:11]) a[i] = [temp1] + [temp3] + [temp2] a = [[a[j][i] for j in range(len(a))] for i in range(len(a[0]))] return a" "def tableFix(table): fixed = [] prev = [] for row in table: if row[0] is None or row == prev: continue prev = row fixed.append(row) return fixed def transponate(tab): return [[tab[j][i] for j in range(len(tab))] for i in range(len(tab[0]))] def tableChange(table): changedTable = [] for row in table: if row[0] == 'Да': bool = '1' elif row[0] == 'Нет': bool = '0' mail = row[1][:row[1].find('[at]')] num = str(round(float(row[2]), 1)) fio = row[3].split(' ') name = '.'.join([fio[0][:1], fio[1][:1], ' ' + fio[2]]) changedTable.append([bool, mail, num, name]) return changedTable def main(table): table = tableFix(table) table = transponate(table) table = tableFix(table) table = transponate(table) table = tableChange(table) table = transponate(table) return table" "def main(x): res = [] for i in range(len(x)): res.append([]) for j in x[i]: if j not in res[i]: res[i].append(j) for i in res: i[0] = i[0].replace('-', '.') i[1] = str(round(int(str(i[1][:-1])) / 100, 1)) i[2] = i[2][1:4] + i[2][6:9] + i[2][10:14] res = sorted(res, key=lambda x: x[2]) return res" "def main(table): parsed = set() (surname, state, newdate, scoreround) = ([], [], [], []) for (name, flag, date, score, _) in table: if name in parsed and name is not None: continue parsed.add(name) surname.append(name.split(' ')[2]) state.append('Да' if flag == 'Выполнено' else 'Нет') newdate.append(date.replace('.', '-')) scoreround.append(f'{score}0') return [surname, state, newdate, scoreround]" "def main(table): fourth_list = [] for i in range(len(table)): table[i] = list(filter(None, table[i])) for i in table: value = str(round(float(i[0].split('#')[0]), 2)) if len(value) == 3: value += '0' fourth_list.append(value) split = i[0].split('#')[1].split(' ') i[0] = ''.join(split[2] + ' ' + split[0][0] + '.' + split[1]) i[1] = ''.join(i[1].split('/')[2]) i[2] = ''.join(i[2].split('@')[1]) final_table = [] names = [] years = [] mail = [] for i in table: names.append(i[0]) years.append(i[1]) mail.append(i[2]) final_table.append(names) final_table.append(years) final_table.append(mail) final_table.append(fourth_list) return final_table" "def main(table): sorted_table = [] for i in table: c = [] for j in i: if j not in c: c.append(j) sorted_table.append(c) cleaned_table = [] for row in sorted_table: if row != [None]: cleaned_table.append(row) for row in cleaned_table: row[0] = row[0].split()[0][0] + '.' + ' '.join(row[0].split()[1:]) row[1] = row[1].split('@')[0] row[2] = 'true' if row[2] == 'Y' else 'false' row[3] = row[3][:-4] + row[3][-2:] return cleaned_table" "def main(array): counter = -1 for i in array: counter += 1 if i[0] is None and i[1] is None and (i[2] is None): array.pop(counter) farray = [] for i in array: if i not in farray: farray.append(i) array = farray for i in range(len(array)): s = array[i][0].replace('.', '/') array[i][0] = s if array[i][2][5] == '1': array[i][1] = 'Да' s = array[i][2].replace('!1', '00') array[i][2] = s else: array[i][1] = 'Нет' s = array[i][2].replace('!0', '00') array[i][2] = s return array" "def remove_same_rows_func_1(t, odds): for el in odds: while t.count(el) > 1: t.pop(len(t) - t[::-1].index(el) - 1) def remove_same_rows_func_2(t, odds, i, j): if j > i: for k in range(len(t[i])): if t[i][k] != t[j][k]: break else: odds.append(t[i]) def remove_same_rows(t): odds = [] for i in range(len(t)): for j in range(len(t)): remove_same_rows_func_2(t, odds, i, j) remove_same_rows_func_1(t, odds) def remove_same_columns_func_1(t, odds): for el in odds: for i in range(len(t)): while t[i].count(el) > 1: t[i].remove(el) def remove_same_columns_func_2(t, odds, i, j): for k in range(len(t)): if j > i and t[k][j] != t[k][i]: break else: for index in range(len(t)): odds.append(t[index][j]) def remove_same_columns(t): odds = [] for i in range(len(t[0])): for j in range(len(t[0])): remove_same_columns_func_2(t, odds, i, j) remove_same_columns_func_1(t, odds) def remove_blank_rows_func_1(t, odds): for el in odds: while el in t: t.remove(el) def remove_blank_rows(t): odds = [] for i in range(len(t)): for j in range(len(t[i])): if t[i][j] is not None: break else: odds.append(t[i]) remove_blank_rows_func_1(t, odds) def remove_blank_columns_1(t, odds): for el in odds: for i in range(len(t)): while el in t[i]: t[i].remove(el) def remove_blank_columns_2(t, odds, i): for j in range(len(t)): if t[j][i] is not None: break else: for index in range(len(t)): odds.append(t[index][i]) def remove_blank_columns(t): odds = [] for i in range(len(t[0])): remove_blank_columns_2(t, odds, i) remove_blank_columns_1(t, odds) def change_table(t): for ti in t: new_value_0 = 'Не выполнено' if ti[0] == 'нет' else 'Выполнено' ti[0] = new_value_0 new_value_1 = '(' + ti[1][3:6] + ') ' + ti[1][7:13] + '-' + ti[1][13:] ti[1] = new_value_1 new_value_2 = ti[2][:6] + ti[2][8:] ti[2] = new_value_2 new_value_3 = ti[3].split()[-1] ti[3] = new_value_3 (ti[1], ti[3]) = (ti[3], ti[1]) (ti[2], ti[3]) = (ti[3], ti[2]) def main(t): remove_blank_rows(t) remove_blank_columns(t) remove_same_rows(t) remove_same_columns(t) change_table(t) return t t1 = [['нет', 'Марат А. Довотиди', '+7 710 704-2158', '05/04/2003', None, 'Марат А. Довотиди'], ['да', 'Амир М. Мигабин', '+7 739 369-3630', '16/11/1999', None, 'Амир М. Мигабин'], [None, None, None, None, None, None], ['да', 'Амир М. Мигабин', '+7 739 369-3630', '16/11/1999', None, 'Амир М. Мигабин'], ['да', 'Амир М. Мигабин', '+7 739 369-3630', '16/11/1999', None, 'Амир М. Мигабин'], [None, None, None, None, None, None], ['да', 'Глеб В. Зомко', '+7 845 775-1576', '28/12/2000', None, 'Глеб В. Зомко'], ['да', 'Ян З. Тецовий', '+7 581 816-2307', '06/10/2004', None, 'Ян З. Тецовий']] t2 = [['нет', 'Дмитрий Б. Цацибман', '+7 803 284-3073', '19/02/1999', None, 'Дмитрий Б. Цацибман'], ['нет', 'Дмитрий Б. Цацибман', '+7 803 284-3073', '19/02/1999', None, 'Дмитрий Б. Цацибман'], ['да', 'Данила З. Локошак', '+7 795 875-9730', '01/10/2000', None, 'Данила З. Локошак'], [None, None, None, None, None, None], [None, None, None, None, None, None], ['нет', 'Дмитрий Б. Цацибман', '+7 803 284-3073', '19/02/1999', None, 'Дмитрий Б. Цацибман'], ['нет', 'Макар К. Дозозский', '+7 984 587-0829', '16/11/2004', None, 'Макар К. Дозозский']] main(t1) main(t2)" "def main(table): remove_indexes = [] for (i, line) in enumerate(table): line[0] = line[0][line[0].find(')') + 2:] line[1] = line[2][:line[2].find('!') - 2] line[2] = line[2][line[2].find('!') + 1:] line[2] = '%.2f' % float(line[2]) if table.count(line) >= 2: remove_indexes.append(i) for i in remove_indexes[::-1]: table.pop(i) return table" "def customKey(row): return row[3] def main(input_list): input_list = [i for i in input_list if len(i) != 0 and i[0] is not None] for row in input_list: for i in row: if row.count(i) > 1: row.remove(i) temp = row[1].split('&') row.remove(row[1]) x = temp[1] while len(x[x.find('.') + 1:]) != 4: x += '0' row.insert(1, x) x = temp[0] x = '(' + x x = x.replace('-', ') ', 1) row.append(x) row[2] = row[2].replace('[at]', '@') row[0] = row[0][:-2] row[0] = row[0].replace(',', '') input_list.sort(key=customKey) return input_list" "import re def main(table): table = remove_duplicate(table) table = remove_empty(table) table = split_by_sep(table) table = remove_initials(table) table = sort(table) table = transposition(table) return table def remove_initials(table): for row in table: row[1] = re.sub('^([а-яА-Я]+\\.+[а-яА-Я]+\\.+) ', '', row[1]) num = re.search('^([0-9]*-[0-9]*-[0-9]*)', row[0]) temp = re.split('-', num.group(0)) word = temp[0] + '-' + temp[1] + temp[2] row[0] = re.sub('^([0-9]*-[0-9]*-[0-9]*)', word, row[0]) row[2] = re.sub('^нет', 'false', row[2]) row[2] = re.sub('^да', 'true', row[2]) return table def transposition(table): temp = [0] * len(table[0]) for i in range(len(table[0])): temp[i] = [0] * len(table) for i in range(0, len(table[0])): for j in range(0, len(table)): temp[i][j] = table[j][i] return temp def sort(table): table.sort(key=lambda table: table[0]) return table def table_income(table): return table[0][0] def split_by_sep(table): temp = [0] * len(table) for i in range(len(table)): temp[i] = [0] * (len(table[0]) + 1) for i in range(0, len(table)): for j in range(0, len(table[0])): if j == 0: temp[i][j] = table[i][j].split(';')[0] temp[i][j + 1] = table[i][j].split(';')[1] continue temp[i][j + 1] = table[i][j] return temp def remove_empty(table): for row in table: if row[0] is None and row[1] is None: table.remove(row) return table def remove_duplicate(table): temp = [] for row in table: if row not in temp: temp.append(row) return temp" "def main(x): count = len(x) while count > 0: del x[count - 1][0] del x[count - 1][1] count -= 1 for i in x: if x.count(i) > 1: x.remove(i) for i in x: percent = i[0][i[0].find(';') + 1:] fio = i[0][:i[0].find(';')] i.append(percent) i[0] = fio for i in x: p = i[1].replace('+7', '+7 (') p = p[:3] + p[3:7] + ') ' + p[7:10] + '-' + p[10:12] + '-' + p[12:] i[1] = p f = i[0] f = f[f.find('.') + 2:] + ' ' + f[:f.find('.') - 2] i[0] = f p = i[2] p = int(p[:len(p) - 1]) p = round(p / 100, 1) p = str(p) i[2] = p x.sort(key=lambda x: x[0]) y = [] templist0 = [] templist1 = [] templist2 = [] for i in x: templist2.append(i[2]) templist1.append(i[1]) templist0.append(i[0]) y.append(templist2) y.append(templist1) y.append(templist0) return y" "def main(_list): for i in _list: while None in i: i.remove(None) for j in range(len(i)): if len(i[j]) == 3: i[j] = float(i[j]) i[j] *= 100 i[j] = int(i[j]) i[j] = str(i[j]) + '%' i[j] = str(i[j]).replace('Y', 'да') i[j] = str(i[j]).replace('N', 'нет') i[j] = str(i[j]).replace('.', '-') while [] in _list: _list.remove([]) return _list" "import re def main(ar): pr = [] ph = [] nm = [] rs = [] def _pr(i): el = ar[i][0] p = el.split('%#')[0] s = str(int(p) / 100) pr.append(s + '0' if len(s) < 4 else s) def _ph(i): el = ar[i][2].split(' ')[1] c = el.split('-') _l = c[0] r = c[1] ph.append(f'{_l}-{r[0:2]}-{r[2:4]}') def _nm(i): el = ar[i][0] n = el.split('%#')[1] a = n.split(' ')[0] b = re.search(' .\\.', n)[0][1:3] nm.append(f'{a} {b}') for (j, _) in enumerate(ar): _pr(j) _ph(j) _nm(j) rs.append([pr[j], ph[j], nm[j]]) return rs" "import json import re def main(table): buffTable = table transTable = [] newTable = [] for i in range(0, len(buffTable)): if buffTable[i] not in newTable: newTable.append(buffTable[i]) dest = len(newTable) dI = 0 for i in range(0, dest): buff = [] allNone = True for j in range(0, len(newTable[i])): if newTable[i][j] is not None: allNone = False regex = '[а-яА-Я]*\\s[а-яА-Я]*' if '[at]' in newTable[i][j]: buff.append(newTable[i][j].split('[at]')[0]) elif re.findall(regex, newTable[i][j]): buff.append(newTable[i][j].split(' ')[1]) elif re.findall('\\d{5,}', newTable[i][j]): b = newTable[i][j] buff.append(b[0] + b[1] + b[2] + '-' + b[3] + b[4] + b[5] + '-' + b[6] + b[7] + b[8] + b[9]) else: buff.append(newTable[i][j]) if not allNone: transTable.append([]) transTable[i - dI] = buff else: dI += 1 return transTable" "def main(table): for i in range(len(table)): table[i].pop(1) table[i].pop(2) table[i].pop(1) d = {'false': 'Нет', 'true': 'Да'} for i in range(len(table)): for j in range(len(table[i])): if table[i][j] in d.keys(): table[i][j] = d[table[i][j]] else: temp = table[i][j].split('#') table[i][j] = temp[0].replace('-', '') item = '%.2f' % round(float(temp[1]), 2) table[i].insert(j, item) return table" "def get_t_table(table): return [list(i) for i in zip(*table)] def delete_empty_columns(table): t_table = get_t_table(table) for i in range(len(t_table)): t_table[i] = [val for val in t_table[i] if val] t_table = [val for val in t_table if val] return get_t_table(t_table) def delete_duplicates(table): tpl = [tuple(row) for row in table] dct = list(dict.fromkeys(tpl)) dup_free = [list(row) for row in dct] return dup_free def main(table): new_table = [] table = delete_empty_columns(table) table = delete_duplicates(table) for row in table: row[0] = row[0].replace('(', '').replace(')', '') row[0] = row[0][3:] row[0] = row[0][:10] + row[0][11:] new_table.append([row[0], row[1].replace('false', 'нет').replace('true', 'да'), '/'.join(row[2].split('-')[::-1])]) return new_table" "import re def main(nbook): n2 = [] for i in nbook: if i not in n2: n2.append(i) nbook = n2 n2 = [] for i in range(len(nbook)): stroka = [] c = 0 for j in range(len(nbook[i]) - 1): if nbook[i][j] is not None: stroka.append(nbook[i][j]) c += 1 if c != 0: n2.append(stroka) for i in range(0, len(n2)): if n2[i][0] == 'Выполнено': n2[i][0] = 'Y' else: n2[i][0] = 'N' stroka = n2[i][1] stroka = stroka.replace(' ', '') stroka = stroka.split('.') stroka = str(stroka[2]) + ' ' + str(stroka[0]) + '.' n2[i][1] = stroka n2[i][2] = re.findall('.*?@', n2[i][2]) n2[i][2][-1] = n2[i][2][-1].replace('@', '') stroka = '' for k in range(len(n2[i][2])): stroka += n2[i][2][k] n2[i][2] = stroka return n2" "import copy def fun(data): new_data = copy.deepcopy(data) for i in new_data: while i.count(None): i.remove(None) for i in new_data: if not i: new_data.remove(i) for i in new_data: i[0] = format(int(i[0].replace('%', '')) / 100, '.4f') tmp = i[1].split(';') i[1] = tmp[0].replace('/', '-') i.append(tmp[1].split(']')[1]) return [[new_data[j][i] for j in range(len(new_data))] for i in range(len(new_data[0]))] def main(tab): return fun(tab)" "def transpouse(mat): matrix = [] for i in range(len(mat[0])): matrix.append(list()) for j in range(len(mat)): matrix[i].append(mat[j][i]) return matrix def delet(List_t: list): List_with_uniq = [] seen = set() for x in List_t: hsh = tuple(x) if hsh not in seen: List_with_uniq.append(x) seen.add(hsh) return List_with_uniq def delet_none(List_with_uniq: list): t = 0 stop = len(List_with_uniq) i = 0 while stop == len(List_with_uniq): for j in range(len(List_with_uniq[0])): if List_with_uniq[i][j] is None: t += 1 if t == len(List_with_uniq[0]): del List_with_uniq[i] t = 0 i += 1 return List_with_uniq def forma(List_with_uniq: list): for i in range(len(List_with_uniq)): for j in range(len(List_with_uniq[0])): if List_with_uniq[i][j][1] == '.': List_with_uniq[i][j] = List_with_uniq[i][j] + '000' elif List_with_uniq[i][j][0] == '+': List_with_uniq[i][j] = List_with_uniq[i][j][7:16] else: List_with_uniq[i][j] = List_with_uniq[i][j].replace('-', '/') return List_with_uniq def main(List: list): return transpouse(forma(delet_none(delet(transpouse(List)))))" "def f(x): if x.split('&')[1] == 'Выполнено': return 'true' else: return 'false' def ff(x): x = x.split('&')[0] return f'{x[:2]} {x[2:5]} {x[5:8]}-{x[8:10]}-{x[10:]}' def fff(x): return x.split(' ')[1] + ' ' + x.split(' ')[0] def dropna(x): x = [[i for i in j if i is not None] for j in x] return [i for i in x if i] def main(a): a = dropna(a) for i in range(len(a)): a[i].insert(0, f(a[i][0])) a[i][1] = ff(a[i][1]) a[i][2] = fff(a[i][2]) return a" "def edit(lst): for i in range(len(lst)): lst[i][4] = None for i in range(len(lst)): lst[i] = list(filter(None, lst[i])) lst = list(filter(None, lst)) for i in range(len(lst)): lst[i][1] = lst[i][1].replace('-', '.') l1 = [] for i in lst: l1.append([]) for i in range(len(lst)): if lst[i][0][0:2] == 'да': l1[i].append('Выполнено') l1[i].append(lst[i][0][10:19]) l1[i].append(lst[i][1]) elif lst[i][0][0:3] == 'нет': l1[i].append('Не выполнено') l1[i].append(lst[i][0][11:20]) l1[i].append(lst[i][1]) return l1 def main(lst): return edit(lst)" "def main(arg): x = [] arg.sort(key=lambda x: x[0]) for person_info in arg: repeat = False for x_info in x: if x_info == person_info: repeat = True if not repeat: x.append(person_info) ans = [] for i in range(len(x[0])): temp = [] for j in range(len(x)): temp.append(x[j][i]) ans.append(temp) emails = [] for mail in ans[0]: i = mail.find('@') email = mail[:i] + '[at]' + mail[i + 1:] emails.append(email) result = [emails] names = [] for firstname in ans[1]: name = firstname[0] + '.' i = firstname.find(' ') + 1 name += firstname[i:] names.append(name) result.append(names) years = [] for year in ans[2]: year_list = year.split('-') years.append(year_list[2] + '-' + year_list[1] + '-' + year_list[0]) result.append(years) return result" "def f(x): x[0] = 'Y' if x[0] == 'да' else 'N' s = x[1].split('/') x[1] = f'{s[0]}.{s[1]}.{s[2]}' x[2] = x[2].split()[0] return x def dropna(x): x = [[i for i in j if i is not None] for j in x] return [i for i in x if i] def dropeq(a): for j in [0, 1]: for i in a: num = a.count(i) while num > 1: a.pop(a.index(i, a.index(i) + 1)) num = a.count(i) a = list(map(list, zip(*a))) a = list(map(f, a)) return a def main(a): a = dropna(a) a = dropeq(a) return a" "def f10_1(matrix): mass = list() for i in matrix: if i not in mass and i is not None: mass.append(i) mass[0] = mass[0].replace('.', '/') mass[1] = mass[1].title() mass[2] = mass[2] + '0' mass[3] = mass[3][:mass[3].find('@')] return mass def main(matr): mass = list() for i in matr: mass.append(f10_1(i)) trans_m = [[mass[j][i] for j in range(len(mass))] for i in range(len(mass[0]))] return trans_m" "import re from itertools import groupby def main(lst): new_lst = rep(lst) var1 = [] var2 = [] for i in range(len(new_lst)): if new_lst[i][2] is not None: new_lst[i][2] = new_lst[i][2].split('!') var1 = new_lst[i][2][0] var2 = new_lst[i][2][1] new_lst[i].pop(2) new_lst[i].insert(2, var1) new_lst[i].insert(3, var2) new_lst = rep(list(map(list, zip(*new_lst)))) for i in range(len(new_lst[0])): if new_lst[0][i] is not None: new_lst[0][i] = new_lst[0][i].split('-') new_lst[0][i] = new_lst[0][i][2] + '/' + new_lst[0][i][1] + '/' + new_lst[0][i][0] new_lst = rep(list(map(list, zip(*new_lst)))) for i in range(len(new_lst)): if new_lst[i][1] is not None: new_lst[i][1] = new_lst[i][1].split('@') new_lst[i][1] = new_lst[i][1][1] if new_lst[i][2] is not None: new_lst[i][2] = new_lst[i][2].replace(' ', '').replace('-', '') if new_lst[i][3] is not None: new_lst[i][3] = new_lst[i][3].split(' ') new_lst[i][3] = new_lst[i][3][1] + ' ' + new_lst[i][3][0] new_lst[i][3] = new_lst[i][3][:len(new_lst[i][3]) - 2] if new_lst[i][2] is not None: t = new_lst[i][2] new_lst[i][2] = new_lst[i][3] new_lst[i][3] = t new_lst.sort(key=lambda x: x[3]) return new_lst def rep(lst): n = [] for i in lst: if i not in n: n.append(i) return n" "def main(table: list[list[str]]): for (i, row) in enumerate(table): if row == [None, None, None]: none = i continue row.append(row[0].split('!')[1]) row[0] = f'{row[0][8:10]}.{row[0][3:5]}.{row[0][:2]}' row[1] = '1' if row[1] == 'Да' else '0' row[2] = row[2].replace('[at]', '@') row[3] = '{0:,.3f}'.format(float(row[3])) table.pop(none) return list(map(list, zip(*table)))" "def change(s): s = list(filter(None, s)) for i in range(len(s)): if ']' in s[i]: s[0] = s[i][s[i].index(']') + 1:s[i].index('#')] if '#' in s[i]: s[i] = str(round(float(s[i][s[i].index('#') + 1:]), 1)) elif 'да' == s[i]: s[i] = 'true' elif 'нет' == s[i]: s[i] = 'false' else: s[i] = s[i].replace('.', '-') return s def new_lists(s): ns1 = [] ns2 = [] ns3 = [] ns4 = [] for s_list in s: ns1.append(s_list[1]) ns2.append(s_list[2]) ns3.append(s_list[3]) ns4.append(s_list[0]) ns = [ns1, ns2, ns3, ns4] return ns def main(s): for i in range(len(s)): s[i] = change(s[i]) s = list(filter(None, s)) return new_lists(s)" "def value_transformation(S): S = S.lstrip() S = S.rstrip('%') if int(S) > 9: S = '0.' + S else: S = '0.0' + S return '{:.4f}'.format(float(S)) def number_transformation(S): S = S.replace('(', '').replace(')', '').replace(' ', '') return S.replace('-', '') def date_reverse(S): tmp = S.split('-') return tmp[2] + '-' + tmp[1] + '-' + tmp[0] def main(List): (l, l0, l1, l2, tmpList) = ([], [], [], [], []) for e in List: tmpList.append(e[0].split('&')) for i in range(len(List)): tmpList[i].append(List[i][2]) for i in range(len(tmpList)): l0.append(value_transformation(tmpList[i][0])) for i in range(len(tmpList)): l1.append(number_transformation(tmpList[i][1])) for i in range(len(tmpList)): l2.append(date_reverse(tmpList[i][2])) return [l0, l2, l1]" "def func(table): while True: flag = 0 for i in range(len(table[0])): count = 1 if table[0][i] is None: for j in range(1, len(table)): if table[j][i] is None: count += 1 if count == len(table): for k in range(len(table)): table[k].pop(i) flag = 1 break if flag == 1: break if flag == 0: break return table def main(table): for i in range(len(table)): for j in range(i + 1, len(table)): if table[j] == table[i] and table[j] != [None, None, None, None]: table[j] = [None, None, None, None] while table.count([None, None, None, None]): table.pop(table.index([None, None, None, None])) table = func(table) for i in range(len(table)): table[i][0] = str(table[i][0])[1:4] + str(table[i][0])[6:9] + str(table[i][0])[10:14] table[i][1] = str(table[i][1]).replace('-', '/') table[i][2] = str(table[i][2])[0:str(table[i][2]).find('[')] return table" "from typing import List def clearNones(rows: List) -> List: res = [] for row in rows: buff = [item is None for item in row] if True not in buff: res.append(row) return res def clearDuplicates(rows: List) -> List: res = [] unpackedRows = [] buff = [] for row in rows: a = ''.join(row) unpackedRows.append(a) for i in range(len(rows)): if unpackedRows[i] not in buff: res.append(rows[i]) buff.append(unpackedRows[i]) return res def addColumn(rows: List) -> List: res = [] for row in rows: string = row[1].split('#') row[1] = row[1].split('#')[0] row.append(string[1]) res.append(row) return res def swapColumns(rows: List) -> List: res = [] for row in rows: buff = row[1] row[1] = row[2] row[2] = buff res.append(row) return res def formatNumber(rows: List) -> List: res = [] for row in rows: first = row[0][-7:-4] second = row[0][-4:-2] third = row[0][-2:] string = first + '-' + second + '-' + third row[0] = string res.append(row) return res def formatDate(rows: List) -> List: res = [] for row in rows: string = row[1].split('/') row[1] = string[2] + '.' + string[1] + '.' + string[0] res.append(row) return res def formatName(rows: List) -> List: res = [] for row in rows: string = row[2].split('.') row[2] = string[0] + '.' + string[2] res.append(row) return res def sortTable(rows: List) -> List: res = [] rows.sort(key=lambda x: x[2]) res.append(rows) return res def main(table: List) -> List: table = clearNones(table) table = clearDuplicates(table) table = addColumn(table) table = swapColumns(table) table = formatNumber(table) table = formatDate(table) table = formatName(table) table = sortTable(table) return table[0]" "def main(table): new_table = [] reuses = [] for row in table: if row not in reuses: reuses.append(row) for row in reuses: row[0] = row[0].split('@')[0] (day, month, year) = row[1].split('.') row[1] = '.'.join([year, month, day]) row[2] = str(round(float(row[2]), 1)) row[3] = row[3].split(' ')[0] for i in range(len(reuses[0])): new_row = [] for row in reuses: new_row.append(row[i]) new_table.append(new_row) return new_table" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] for i in data: (i[2], i[1]) = i[1].split('!') i.remove(None) date = datetime.strptime(i[0], '%Y-%m-%d') i[0] = date.strftime('%d/%m/%Y') i[1] = i[1].replace('@', '[at]') i[2] = str(round(float(i[2]), 2)) if len(i[2]) == 3: i[2] = str(i[2]) + '0' new_table = [] for j in range(3): row = [] for i in data: row.append(i[j]) new_table.append(row) return new_table" "import re def main(table): tmp_tb = [] for y in table: if y[0] is not None: t = [] for x in y: if x is not None: t.append(x) tmp_tb.append(t) for i in range(len(tmp_tb)): str1 = re.search('\\w+@', tmp_tb[i][0])[0] str2 = str1[:len(str1) - 1] tmp_tb[i][0] = str2 tmp_tb[i][1] = tmp_tb[i][1][2:] tmp_tb[i][1] = tmp_tb[i][1].replace('/', '.') if tmp_tb[i][2][0] == 'н' or tmp_tb[i][2][0] == 'Н': tmp_tb[i][2] = 'false' else: tmp_tb[i][2] = 'true' tmp_tb[i][3] = tmp_tb[i][3][2:] tmp_tb[i][3] = tmp_tb[i][3][0:3] + ' ' + tmp_tb[i][3][3:] tmp_tb[i][3] = tmp_tb[i][3][0:7] + '-' + tmp_tb[i][3][7:] return tmp_tb" "from datetime import datetime def change(s): s = list(filter(None, s)) for i in range(len(s)): if '(' in s[i]: s[i] = s[i][s[i].index('(') + 1:s[i].index(')')] + s[i][s[i].index(')') + 1:] elif '.' in s[i]: s[i] = s[i][s[i].index('.') + 2:] + ' ' + s[i][0] + '.' + s[i][s[i].index('.') - 1] + '.' elif '1' == s[i]: s[i] = 'true' elif '0' == s[i]: s[i] = 'false' elif '/' in s[i]: s[i] = s[i].replace('/', '.') a = s[i][s[i].index('.') + 1:][s[i].index('.') + 1:] b = '.' + s[i][s[i].index('.') + 1:][:s[i].index('.') + 1] c = s[i][:s[i].index('.')] s[i] = a + b + c return s def main(s): for i in range(len(s)): s[i] = change(s[i]) s = list(filter(None, s)) s = sorted(s, key=lambda s_list: datetime.strptime(s_list[0].split()[-1], '%Y.%m.%d')) return s" "from itertools import groupby import re def toFixed(numObj, digits=0): return f'{numObj:.{digits}f}' def main(x): list = [el for (el, _) in groupby(x)] tables = [] for item in list: if item not in tables: tables.append(item) result = [] a = '' b = '' d = '' mail_array = [] procent_array = [] date_array = [] fio_array = [] for i in range(len(tables)): a = a.join(re.findall('^[^@]*@([\\s\\S]*)$', tables[i][0])) b = b.join(re.findall('^(.*?)%$', tables[i][1])) new_b = toFixed(int(b) / 100, 2) c = str(tables[i][2]).replace('.', '-') firstname = d.join(re.findall('(.*?),', tables[i][3])) name = d.join(re.findall('^[^,]*,([\\s\\S]*)..', tables[i][3])) name = name.replace(' ', '') fio = name + ' ' + firstname mail_array.append(a) procent_array.append(new_b) date_array.append(c) fio_array.append(fio) result.append(mail_array) result.append(procent_array) result.append(date_array) result.append(fio_array) return result" "def remove(duplicate): final_list = [] for num in duplicate: if num not in final_list: final_list.append(num) return final_list def mail(string: str): x = string.split(']') return x[1] def name(string: str): x = string.replace(',', '') return x[0:-2] def sort(x): sorted_list = sorted(x, key=lambda x: x[1]) return sorted_list def main(x: list): for i in range(len(x)): buf = [] for el in x[i]: if el is None: pass else: buf.append(el) x[i] = buf x = remove(x) result = [] for el in x: result.append([mail(el[0]), name(el[1]), el[2] + '00']) result = sort(result) rez = [[result[j][i] for j in range(len(result))] for i in range(len(result[0]))] return rez" "import re from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] for i in data: if i[2] == i[4]: i.pop(4) date = datetime.strptime(i[3], '%Y-%m-%d') i[3] = date.strftime('%y-%m-%d') i[0] = re.sub('.*\\[at]', '', i[0]) i[1] = i[1][0:2] + i[1][4:] i[2] = i[2][:12] + '-' + i[2][12:] new_table = [] for j in range(4): row = [] for i in data: row.append(i[j]) new_table.append(row) return new_table" "import copy def main(x): x = deleteEmptyColumns(x) x = parseNumbers(x) x = parseDates(x) x = parseNames(x) x = sortNumbers(x) x = changeTable(x) return x def deleteEmptyColumns(array): for i in array: for counter in range(i.count(None)): i.remove(None) return array def parseNumbers(array): for i in array: buff = i[0].split(' ') ans = buff[2] i[0] = ans return array def parseDates(array): for i in array: buff = i[1].split('-') ans = buff[2] + '-' + buff[1] + '-' + buff[0] i[1] = ans return array def parseNames(array): for i in array: buff = i[2].split(' ') ans = buff[2] + ', ' + buff[0][0] + '.' + buff[1] i[2] = ans return array def sortNumbers(array): a = ['', '', '', ''] k = 0 for i in array: buff = i[0].split('-') a[k] = buff[0] k += 1 b = copy.deepcopy(a) if b[-1] == '': b.pop(-1) changed = True while changed: changed = False for i in range(len(b) - 1): if int(b[i]) > int(b[i + 1]): changed = True (b[i], b[i + 1]) = (b[i + 1], b[i]) list = [[], [], [], []] k = 0 for k in range(4): for n in range(len(array)): if b[n] == a[k]: list[n] = array[k] return list def changeTable(array): ans = [[], [], []] for i in array: for k in range(len(i)): ans[k].append(i[k]) return ans" "def main(table): newTable = [] for i in range(len(table)): for j in range(i + 1, len(table)): if table[i] == table[j]: table[j] = [None, None] for i in table: if i != [None, None]: row = [] sp = i[0].split(';') row.append(f'{sp[1][5:8]}-{sp[1][8:10]}-{sp[1][10:12]}') row.append('%.4f' % round(int(sp[0][:-1]) / 100, 4)) row.append('true' if i[1] == 'Y' else 'false') newTable.append(row) return newTable" "def main(array): result = [] for row in array: row_result = [] for el in row: if el is None: continue elif '&' in el: string = el.split('&') row_result.append(string[0][0] + '.' + string[0][string[0].find(' ') + 1:]) row_result.append(string[1].replace('-', '')) else: row_result.append(el[6:] + '/' + el[3:5] + '/' + el[0:2]) (row_result[1], row_result[2]) = (row_result[2], row_result[1]) result.append(row_result) result.sort(key=lambda x: x[2]) return result" "class MyItem: email = '' date = '' second_name = '' is_yes = '' def __init__(self, email, date, date1): self.init_is_yes(email) self.init_email(email) self.init_date_convert(date) self.second_name = date def init_email(self, email): remove_part_email = '' is_bracket = False for symbol in email: if symbol == '[': is_bracket = True if is_bracket: remove_part_email += symbol self.email = str(email).replace(remove_part_email, '') def init_is_yes(self, email): split_email = str(email).split('#') if len(split_email) >= 2 and split_email[1] == '1': self.is_yes = 'да' else: self.is_yes = 'нет' def init_date_convert(self, date): dates = list(str(date).split('.')) dates.reverse() result = '' for item in dates: if len(item) > 2: item = item[2:] result += item + '/' result = result[0:len(result) - 1] self.date = result def map_email(table): result = list() for item in table: result.append(item.email) return result def map_is_yes(table): result = list() for item in table: result.append(item.is_yes) return result def map_first_name(table): result = list() for item in table: result.append(item.date) return result def zxc(list_obj, obj): for result_obj in list_obj: if result_obj.email == obj.email and result_obj.date == obj.date and (result_obj.second_name == obj.second_name): return True return False def main(table): list_obj = list() for item in table: obj = MyItem(item[1], item[2], item[3]) is_contains = False if obj.email is None or obj.date is None or obj.second_name is None: continue is_contains = zxc(list_obj, obj) if is_contains: continue list_obj.append(obj) result = list() result.append(map_email(list_obj)) result.append(map_is_yes(list_obj)) result.append(map_first_name(list_obj)) return result" "def main(table): result_table = [] for line in table: line = set(line) column_begin = None for item in line: if item is None: break if '#' in item: split = item.split('#') column_begin = '/'.join(reversed(split[0].split('/'))) column_end = str(round(float(split[1]), 1)) if '+' in item: column_center = item.split()[2] if not column_begin: continue new_line = [column_begin, column_center, column_end] if new_line not in result_table: result_table.append(new_line) return result_table" "import re from decimal import Decimal def transpose(table): res = [] n = len(table) m = len(table[0]) for j in range(m): tmp = [] for i in range(n): tmp = tmp + [table[i][j]] res = res + [tmp] return res def delete_dupl(table): new_table = [] for row in table: new_table.append(row) for i in range(len(new_table)): for y in range(len(new_table)): if i != y and new_table[i] == new_table[y]: new_table[y] = [None] * len(new_table[y]) return new_table def delete_empty(table): new_table = table i = 0 while i < len(new_table): if len(new_table[i]) == 0 or set(new_table[i]) == {None}: new_table.pop(i) i -= 1 i += 1 return new_table def convert_cells(table): new_table = [] for row in table: new_row = [] for i in range(len(row)): cell = row[i] new_cell = None if i == 0: new_cell = re.split(',', cell)[0] elif i == 1: if cell == 'true': new_cell = 'Y' else: new_cell = 'N' elif i == 2: new_cell = re.sub('(\\[at\\])+', '@', cell) elif i == 3: new_cell = str(round(Decimal(float(cell)) * 100)) + '%' new_row.append(new_cell) new_table.append(new_row) return new_table def sort_table(table): table.sort(key=lambda row: row[0]) return table def f(table: list) -> list: table = transpose(delete_empty(transpose(table))) table = delete_dupl(table) table = delete_empty(table) table = convert_cells(table) table = sort_table(table) return table def main(x): return f(x)" "def main(table): emails = [] percent = [] data = [] names = [] for line in table: s = line[0].split('[at]')[0] if s not in emails: emails.append(s) s = f'{int(float(line[1]) * 100)}%' if s not in percent: percent.append(s) m = line[3].split('.') s = f'{m[2]}.{m[1]}.{m[0][-2:]}' if s not in data: data.append(s) m = line[4].split() s = f'{m[0][0]}.{m[1]} {m[2]}' if s not in names: names.append(s) return [emails, percent, data, names]" "import re from itertools import groupby from operator import itemgetter def main(data): result_data = [] for i in data: inner_sorted = [el for (el, _) in groupby(i)] result_data_inner = [] for j in range(len(inner_sorted)): if j == 0: result_data_inner.append('{:.3f}'.format(round(float(inner_sorted[j]), 3))) elif j == 1: result_data_inner.append(re.search('(.*?)]', inner_sorted[j]).group()[:-4]) elif j == 2: temp = inner_sorted[j].replace('.', '-') result_data_inner.append(temp) result_data.append(result_data_inner) return sorted(result_data, key=itemgetter(1))" "class Table(object): def __init__(self, table): self.content = table self.length = len(table) self.width = len(table[0]) person_info = [] def get_content(self): return self.content def delete_doubles(self): double_indexes = self.find_doubles() for i in range(len(double_indexes), 0, -1): self.delete_double_by_index(double_indexes[i - 1]) self.update_length() def find_doubles(self): indexes = [] for i in range(1, self.length): for j in range(i): if self.are_full_doubles(i, j): indexes.append(i) break return indexes def are_full_doubles(self, original, checking): if self.content[original] == self.content[checking]: return True return False def delete_double_by_index(self, double_index): self.content.pop(double_index) def update_length(self): self.length = len(self.content) def convert_content(self): for person in self.content: self.person_info = person self.convert_number() self.convert_bool() self.convert_name() def convert_number(self): rounding_number = float(self.person_info[0]) rounding_number = round(rounding_number, 1) writed_string = str(rounding_number) self.person_info[0] = writed_string def convert_bool(self): if self.person_info[1] == 'Y': self.person_info[1] = 'true' else: self.person_info[1] = 'false' def convert_name(self): comma_index = self.person_info[2].find(',') self.person_info[2] = self.person_info[2][:comma_index] def transponse(self): self.add_columns() for i in range(1, self.length): for j in range(i): self.swap(i, j) self.cut_surples() def add_columns(self): if self.enough_columns(): return num_of_adding_columns = self.get_difference_length_width() for person in self.content: for i in range(num_of_adding_columns): person.append('') def get_difference_length_width(self): return self.length - len(self.content[0]) def enough_columns(self): if self.get_difference_length_width() != 0: return False return True def swap(self, i_ind, j_ind): temp = self.content[i_ind][j_ind] self.content[i_ind][j_ind] = self.content[j_ind][i_ind] self.content[j_ind][i_ind] = temp def cut_surples(self): for i in range(self.width, self.length): self.content.pop() def main(input_table): table = Table(input_table) table.delete_doubles() table.convert_content() table.transponse() return table.get_content()" "class Table: table = [] def __init__(self, table): self.table = table def getTable(self): return self.table def __sumOfCol(self, index): col = '' for i in range(len(self.table)): col += str(self.table[i][index]) return col def __deleteCol(self, index): for i in range(len(self.table)): self.table[i].pop(index) def __isEmptyRow(self, index): for i in range(len(self.table[index])): if self.table[index][i] is not None: return False return True def __isEmptyCol(self, index): for i in range(len(self.table)): if self.table[i][index] is not None: return False return True def __isDubbedRows(self): j = 0 while j < len(self.table): i = 0 while i < len(self.table): if self.table[i] == self.table[j] and i != j: return [True, i, j] i += 1 j += 1 return [False, 0, 0] def deleteDubbedRows(self): dubbedData = self.__isDubbedRows() while dubbedData[0]: if dubbedData[1] < dubbedData[2]: self.table.pop(dubbedData[2]) else: self.table.pop(dubbedData[1]) dubbedData = self.__isDubbedRows() def deleteDubbedCols(self): for startIndex in range(int(len(self.table[0]) - 1)): currentCol = self.__sumOfCol(startIndex) for i in range(startIndex + 1, len(self.table[0]) - 1): if currentCol == self.__sumOfCol(i) and startIndex != i: self.__deleteCol(i) def deleteEmptyRows(self): i = 0 while i < len(self.table): if self.__isEmptyRow(i): self.table.pop(i) i += 1 def deleteEmptyCols(self): i = 0 while i < len(self.table[0]): if self.__isEmptyCol(i): self.__deleteCol(i) i += 1 def formatCells(self): for i in range(len(self.table)): for j in range(len(self.table[i])): if self.table[i][j] == 'нет': self.table[i][j] = 'false' elif self.table[i][j] == 'да': self.table[i][j] = 'true' elif len(self.table[i][j]) == 8 and '-' in self.table[i][j]: self.table[i][j] = self.table[i][j].replace('-', '/') elif ',' in self.table[i][j]: temp = self.table[i][j][0:self.table[i][j].index(',')] self.table[i][j] = temp else: temp = self.table[i][j].replace('(', ' (') temp = temp.replace(')', ') ') self.table[i][j] = temp def main(array): table = Table(array) table.deleteDubbedCols() table.deleteEmptyCols() table.deleteDubbedRows() table.deleteEmptyRows() table.formatCells() return table.getTable()" "def get_phone(phone): phone = phone[phone.find(')') + 2:] ind = phone.rfind('-') phone = phone[:ind] + phone[ind + 1:] return phone def get_date(date): ind = date.rfind('.') date = date[ind + 1:] return date def get_email(email): email = email.replace('[at]', '@') return email def get_bool_val(val): if val == 'нет': return 'Не выполнено' else: return 'Выполнено' def sort_table(table): table = [list(filter(None, table[i])) for i in range(len(table))] return sorted(table, key=lambda x: x[2]) def main(table): table = sort_table(table) res_table = [[] for _ in range(4)] for i in range(len(table)): row = table[i] phone = get_phone(row[0]) date = get_date(row[1]) email = get_email(row[2]) bool_val = get_bool_val(row[3]) res_table[0].append(phone) res_table[1].append(date) res_table[2].append(email) res_table[3].append(bool_val) return res_table" "def main(x): table = [] for i in x: if i not in table: table.append(i) for i in table: i[0] = i[0][i[0].find(']') + 1:] i[1] = i[1] + 3 * '0' i[2] = i[2][:-2] if i[3] == 'Y': i[3] = 'true' else: i[3] = 'false' ex_table = [] r_1 = [] r_2 = [] r_3 = [] r_4 = [] for i in table: r_1.append(i[0]) r_2.append(i[1]) r_3.append(i[2]) r_4.append(i[3]) ex_table.append(r_1) ex_table.append(r_2) ex_table.append(r_3) ex_table.append(r_4) return ex_table" "def main(a): res = list() res1 = list() for i in a: if i[0] is None: continue index = i[0].find(':') tmp_s = i[0][index + 1:] res1.append(f'{round(float(tmp_s), 2):.2f}') res.append(res1) res2 = list() for i in a: if i[0] is None: continue index = i[0].find(':') tmp_s = i[0][:index].replace('@', '[at]') res2.append(tmp_s) res.append(res2) res3 = list() for i in a: if i[0] is None: continue tmp = i[2].split() res3.append(tmp[2]) res.append(res3) return res" "import re def main(args): for person_list in args: del person_list[3] for person_list in args: if person_list[0] == 'N': person_list[0] = 'false' else: person_list[0] = 'true' elements_mail = re.split('at]', person_list[1]) person_list[1] = elements_mail[1] number = re.search('\\d+', person_list[2]) person_list[2] = str(round(int(number.group()) / 100, 1)) elements_name = re.split('\\s', person_list[3]) person_list[3] = elements_name[1] return args" "def change(s): for i in range(len(s)): if '!' in s[i]: s1 = s[i][0] s2 = '' for j in range(2, len(s[i])): if s[i][j] != '[': s2 += s[i][j] else: if s1 == '1': s[0] = 'Выполнено' else: s[0] = 'Не выполнено' s[1] = s2 break if '.' in s[i]: s3 = int(round(float(s[i]) * 100, 0)) s[i] = str(s3) + '%' return s def new_lists(s): ns1 = [] for i in range(len(s)): ns1.append(s[i][1]) ns1 = sorted(ns1) for i in range(len(s)): for j in range(i, len(s)): if ns1[i] == s[j][1]: d = s[i] s[i] = s[j] s[j] = d return s def main(s): for i in range(len(s)): s[i] = change(s[i]) return new_lists(s)" "def change(s): s[0] = s[1][14:] s[1] = s[1][0:3] + '-' + s[1][3:5] + '-' + s[1][5:7] for i in range(len(s)): if s[i].__eq__('true'): s[2] = '1' elif s[i].__eq__('false'): s[2] = '0' return s def strings(s): check = True for i in range(len(s)): if s[i] is not None: check = False return check def new_lists(s): ns1 = s[1].copy() s[1] = s[2] s[2] = ns1 return s def transpose(s): ns1 = [] ns2 = [] ns3 = [] for s_list in s: ns1.append(s_list[0]) ns2.append(s_list[1]) ns3.append(s_list[2]) ns = [ns1, ns2, ns3] return ns def main(s): a = [] for i in range(len(s)): if strings(s[i]): a.append(i) for i in range(len(a)): del s[a[i]] s[0] = s[0][0:3] s[1] = s[1][0:3] s[2] = s[2][0:3] for i in range(len(s)): s[i] = change(s[i]) s = transpose(s) s = new_lists(s) return s" "def main(a): x = [] for i in a: if i[0] is None: del i else: b = i[0].split('!') del i[0] x.append(list(set(i)) + b) for i in x: if i[0] is None: del i[0] else: del i[1] s = [] ans = [] for i in range(len(x[0])): temp = [] for j in range(len(x)): temp.append(x[j][i]) ans.append(temp) for i in range(len(ans[1])): ans[1][i] = '(' + ans[1][i][0:3] + ') ' + ans[1][i][3:6] + '-' + ans[1][i][6:8] + '-' + ans[1][i][8:] for i in range(len(ans[2])): c = ans[0][i].split() s.append(ans[2][i]) ans[2][i] = str(c[0]) + ' ' + str(c[2]) for i in range(len(ans[0])): ans[0][i] = s[i][2:] return ans" "def toFixed(numObj, digits=0): return f'{numObj:.{digits}f}' def todo(s): s = list(filter(None, s)) for i in range(len(s)): if '@' in s[i]: s.append(s[i][:s[i].index('@')]) s[i] = toFixed(round(float(s[i][s[i].index(':') + 1:]), 2), 2) elif '.' in s[i] and '@' not in s[i]: s[i] = s[i][0] + '.' + s[i][s[i].index(' '):] elif '/' in s[i]: s[i] = s[i].replace('/', '.') a = s[i][s[i].index('.') + 1:][s[i].index('.') + 1:] b = '.' + s[i][s[i].index('.') + 1:][:s[i].index('.') + 1] c = s[i][:s[i].index('.')] s[i] = c + b + a s.reverse() for x in s: if s.count(x) > 1: s.remove(x) s.reverse() return s def main(s): for i in range(len(s)): s[i] = todo(s[i]) s = list(filter(None, s)) s.sort() s.reverse() for x in s: if s.count(x) > 1: s.remove(x) s.reverse() s2 = [[row[i] for row in s] for i in range(len(s[0]))] return s2" "from ast import match_case def main(a): for i in range(len(a)): for j in range(len(a[i])): match j: case 0: if a[i][j] == 'Выполнено': a[i][j] = 'true' else: a[i][j] = 'false' case 1: a[i][j] = a[i][j].replace('.', '-') case 2: temp = int(a[i][j][a[i][j].find('&') + 1:-1]) / 100 a[i][j] = a[i][j][:a[i][j].rfind('.') - 1] a[i].insert(2, '%.3f' % temp) return a" "def main(in_tbl): out_tbl = [] for line in in_tbl: if None not in line: c1_c3 = line[0].split('#') c2 = line[1].split('.') col1 = f'{c1_c3[0]}0' col2 = f'{c2[0]}.{c2[2]}' col3 = 'true' if c1_c3[1].startswith('Y') else 'false' out_tbl.append([col1, col2, col3]) return out_tbl" "import re def del_column(table): res_table = [] for i in table: buff = [] for t in i: if t is not None: buff.append(t) res_table.append(buff) return res_table def main(table): empty_row = [None for col in range(len(table[0]))] new_table = [] for i in table: first = True for c in range(len(table)): if (i == table[c]) & first: first = False continue elif i == table[c]: table[c] = empty_row for i in table: if i != empty_row: i[0] = str(i[0]) + '0' i[3] = re.split('-', i[3]) i[3] = '/'.join(i[3][::-1]) i[4] = i[4].replace(' ', '-') new_table.append(i) return del_column(new_table)" "def reverse_first_and_last_words(row, symbol): splited = row.split(symbol) return symbol.join(reversed(splited)) def f10(draft_table): table = [] for row in draft_table: row = list(filter(None, row)) if row not in table: table.append(row) for row in table: email_and_name = row[0].split('#') row.insert(0, email_and_name[0].replace('[at]', '@')) row[1] = email_and_name[1] row[2] = row[2].replace('.', '-') table = sorted(table, key=lambda row: row[0]) for row in table: (row[0], row[1]) = (row[1], row[0]) (row[1], row[2]) = (row[2], row[1]) row[0] = reverse_first_and_last_words(row[0], ' ') row[1] = reverse_first_and_last_words(row[1], '-') transposed = [[0 for j in range(len(table))] for i in range(len(table[0]))] for i in range(len(table)): for j in range(len(table[0])): transposed[j][i] = table[i][j] return transposed def main(draft_table): return f10(draft_table)" "def main(s): removed = 0 for i in range(0, len(s)): if s[i][0] is None: s.pop(i) break for i in range(1, len(s)): for k in range(i - removed): if list(set(s[i - removed]) - set(s[k])) == []: s.pop(i - removed) removed = removed + 1 break if i + 1 > len(s): break s = list(map(list, zip(*s))) s.pop(3) for j in range(len(s[0])): t = str(s[0][j]).find('|') if s[0][j][t + 1:t + 3] == 'Да': s[1][j] = 'Y' else: s[1][j] = 'N' s[0][j] = s[0][j][:t] s[0][j] = '-'.join(s[0][j].split('.')[::-1]) k = s[2][j][7:13] k2 = s[2][j][14:] s[2][j] = k + k2 return s" "def main(a): size = list(reversed(range(len(a)))) for i in size: if a.count(a[i]) > 1: size.pop() del a[i] size = list(range(len(a))) for i in size: a[i].pop(2) for j in range(len(a[i])): match j: case 0: temp = a[i][j].split('.') a[i][j] = temp[2] + '/' + temp[1] + '/' + temp[0] case 1: letter = a[i][j][:1] + '.' a[i][j] = letter + a[i][j][a[i][j].find(' ') + 1:] case 2: a[i][j] = a[i][j][a[i][j].find('@') + 1:] res = [[0 for j in range(len(a))] for i in range(len(a[0]))] for i in size: for j in range(len(a[0])): res[j][i] = a[i][j] return res" "def main(table): for i in table: for j in i: if not j: table[table.index(i)].remove(j) x = len(table) y = len(table[0]) table_tr = [''] * y for i in range(len(table_tr)): table_tr[i] = [''] * x for i in range(len(table)): for j in range(len(table[i])): table_tr[j][i] = table[i][j] for j in range(len(table_tr[0])): b = table_tr[0][j] table_tr[0][j] = f'({b[3:6]}) {b[7:10]}-{b[11:13]}-{b[13:]}' table_tr[1][j] = table_tr[1][j].replace('/', '.') table_tr[2][j] = 'Да' if table_tr[2][j] == 'true' else 'Нет' table_tr[3][j] = 'Да' if table_tr[3][j] == 'true' else 'Нет' table_tr.remove(table_tr[3]) return table_tr" "class Modlist: indexBad = -1 def __init__(self, listLine): self.matrix = listLine def deleteDuplicateColumns(self): for i in range(len(self.matrix[0]) - 2): for j in range(i + 1, len(self.matrix[0])): if self.matrix[0][i] == self.matrix[0][j]: self.indexBad = j break rows = len(self.matrix) for i in range(rows): _ = self.matrix[i].pop(self.indexBad) def deleteDuplicateRows(self): for i in range(len(self.matrix) - 2): for j in range(i + 1, len(self.matrix)): if self.matrix[i][0] == self.matrix[j][0]: self.indexBad = j break _ = self.matrix.pop(self.indexBad) def normalizeData(self): for i in range(len(self.matrix)): self.matrix[i][0] = self.matrix[i][0].split(' ')[0] self.matrix[i][1] = '{0:.3f}'.format(float(self.matrix[i][1])) self.matrix[i][2] = self.matrix[i][2].replace('/', '-') self.matrix[i][3] = self.matrix[i][3].split('[')[0] def transpose(self): res = [[self.matrix[j][i] for j in range(len(self.matrix))] for i in range(len(self.matrix[0]))] return res def main(list1): o = Modlist(list1) o.deleteDuplicateColumns() o.deleteDuplicateRows() o.normalizeData() return o.transpose()" "def main(table): new_table = list() for row in table: if row not in new_table and set(row) != {None}: new_table.append(row) table = list(map(list, zip(*new_table))) del table[0] del table[1] table = list(map(list, zip(*table))) new_table = list() for row in table: (date, ratio) = row[0].split('!') date = date.replace('.', '-') ratio = str(round(float(ratio[:-1]) / 100, 1)) email = row[1].split('@')[1] (number_code, *number_main) = row[2].split('-') number = f""{number_code} {'-'.join(number_main)}"" new_table.append([date, email, ratio, number]) new_table.sort(key=lambda x: x[3]) table = list(map(list, zip(*new_table))) return table" "from re import search, purge def s0(a): for i in a: if i is None: continue else: return False return True def s1(a): emp = 0 for x in range(len(a[0])): col = [] for y in range(len(a)): col.append(a[y][x]) if s0(col): emp = x for y in range(len(a)): a[y].pop(emp) return a def s2(a): for i in range(len(a)): for j in range(len(a)): if i != j and a[i] == a[j]: a[j] = [] a = list(filter(lambda a: a != [], a)) return a def s4(a): s = [] height = len(a[0]) width = len(a) for i in range(height): s.append([]) for j in range(width): s[i].append('') for i in range(width): for j in range(height): s[j][i] = a[i][j] return s def s3(a): purge() for i in range(len(a)): a[i][0] += '00' purge() for i in range(len(a)): purge() match = search('.*@(.*)', a[i][1]) if match: a[i][1] = match.group(1) purge() for i in range(len(a)): match = search('([0-9]+)\\-([0-9]+\\-[0-9]+)', a[i][2]) if match: a[i][2] = '(' + match.group(1) + ') ' + match.group(2) purge() return a def main(s): s = s1(s) s = s2(s) s = s3(s) s = s4(s) return s" "def main(table): res = list() for i in table: tmp_list = list() a = i[0][:i[0].find(':')].split() a[2] = a[2].split('-') tmp_list.append(f'({a[1]}) {a[2][0]}-{a[2][1]}{a[2][2]}') b = i[3].replace(',', ' ').replace('.', '. ').split() tmp_list.append(f'{b[1]} {b[0]}') c = i[0][i[0].find(':') + 1:].split('/') tmp_list.append(f'{c[2]}-{c[1]}-{c[0]}') tmp_list.append('Выполнено' if i[4] == 'Да' else 'Не выполнено') res.append(tmp_list) return res" "def change(s): s = list(filter(None, s)) for i in range(len(s)): if ' ' in s[i]: s[0] = s[i][s[i].rindex(' ') + 1:] + ' ' + s[i][:s[i].index(' ')] if '&' in s[i]: s[1] = s[i][:s[i].index('&')] if '1' == s[1]: s[1] = 'Y' elif '0' == s[1]: s[1] = 'N' if '-' in s[i]: s[2] = s[i][s[i].index('-') + 1:s[i].rindex('-')] + '-' + s[i][s[i].rindex('-') + 1:12] + '-' + s[i][12:] return s def main(s): for i in range(len(s)): s[i] = change(s[i]) return s" "def main(matrix): for string in matrix: if string.count(None) > 1: matrix.remove(string) for string in matrix: number_and_surname = string[1].split('|') string[0] = number_and_surname[1].split()[0] string[1] = number_and_surname[0].translate({ord(i): None for i in ' -'}) if string[3] == 'Не выполнено': string[3] = 'false' else: string[3] = 'true' string.pop() string[2] = string[2].replace('@', '[at]') return matrix" "def change(s): s = list(filter(None, s)) for i in range(len(s)): if '-' in s[i]: if s[i][len(s[i]) - 2:] == 'se': s.append('N') else: s.append('Y') s[0] = s[i][s[i].rindex('-') + 1:s[i].index(':')] if '+' in s[i]: s[i] = s[i][:2] + '(' + s[i][2:5] + ')' + s[i][5:8] + '-' + s[i][8:10] + '-' + s[i][10:] return s def new_lists(s): ns1 = [] ns2 = [] ns3 = [] for s_list in s: ns1.append(s_list[0]) ns2.append(s_list[2]) ns3.append(s_list[1]) ns = [ns1, ns2, ns3] return ns def main(s): for i in range(len(s)): s[i] = change(s[i]) s = list(filter(None, s)) new_s = [] for item in s: if item not in new_s: new_s.append(item) return new_lists(new_s)" "def main(inp): out = [] for row in inp: filtered_row = [] for i in range(len(row)): if row[i] is not None: filtered_row.append(row[i]) if len(filtered_row): out.append(filtered_row) for row in out: a = row[0].split(' ') row[0] = '{} {}'.format(a[2], a[0]) if row[1] == 'Да': row[1] = 'Выполнено' else: row[1] = 'Не выполнено' row[2] = '+7({}){}-{}-{}'.format(row[2][2:-7], row[2][-7:-4], row[2][-4:-2], row[2][-2:]) date = row[3].split('-') row[3] = '{}-{}-{}'.format(date[0], date[1], date[2][-2:]) return out" "def main(x): x = deleteEmptyColumns(x) x = deleteExcess(x) x = makeBool(x) x = reverseData(x) x = addZero(x) x = killDog(x) x = sortList(x) return x def sortList(array): array.sort(key=lambda x: x[2]) return array def killDog(array): for i in range(len(array)): array[i][2] = array[i][2].replace('@', '[at]') return array def addZero(array): for i in range(len(array)): array[i][1] = array[i][1] + '00' return array def reverseData(array): for i in range(len(array)): array[i][0] = ''.join(array[i][0][8] + array[i][0][9] + '/' + array[i][0][5] + array[i][0][6] + '/' + array[i][0][0] + array[i][0][1] + array[i][0][2] + array[i][0][3]) return array def deleteExcess(array): for i in range(len(array)): array[i].pop(2) return array def makeBool(array): for i in range(len(array)): match array[i][3]: case '1': array[i][3] = 'Y' case '0': array[i][3] = 'N' return array def deleteEmptyColumns(array): for i in array: for counter in range(i.count(None)): i.remove(None) return array" "def change_date(date): date = date.split('.') return f'{date[0]}/{date[1]}/{date[2][2:]}' def change_email(email): at_index = email.find('[at]') + 4 return email[at_index:] def main(table): table = list(filter(lambda row: row != [None], map(lambda row: list(dict.fromkeys(row)), table))) table = list(map(list, zip(*table))) table = list(filter(lambda row: row != [None] * len(table[0]), table)) table[0] = list(map(lambda num: num[3:6] + '-' + num[6:8] + '-' + num[8:], table[0])) table[1] = list(map(lambda num: f'{float(num):.4f}', table[1])) table[2] = list(map(change_date, table[2])) table[3] = list(map(change_email, table[3])) return table" "def change(s): new_s = [0, 0, 0] new_s[0] = str('%.2f' % (float(s[0][s[0].find('!') + 1:-1]) / 100)) new_s[1] = s[1][:s[1].find('[')] if 'true' in s[0]: new_s[2] = 'Выполнено' else: new_s[2] = 'Не выполнено' return new_s def main(s): for i in range(len(s)): s[i] = change(s[i]) new_s = [] for i in range(len(s)): if s[i] not in new_s: new_s.append(s[i]) return new_s" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] for i in data: i[0] = str(round(float(i[0]), 3)) if len(i[0]) == 4: i[0] = str(i[0]) + '0' split = i[2].split('&') if split[0] == 'Да': i[1] = '1' else: i[1] = '0' date = datetime.strptime(split[1], '%d.%m.%Y') i[2] = date.strftime('%Y/%m/%d') return data" "def main(table): res = list() for i in table: if i[0] is None: continue tmp = list() tmp.append('{:.3f}'.format(float(i[0]))) a = i[1].split('/') tmp.append(f'{a[2]}/{a[1]}/{a[0]}') tmp.append(i[2][:6] + '-' + i[2][6:]) tmp.append('Да' if i[3] == 'Выполнено' else 'Нет') if tmp not in res: res.append(tmp) return res" "def main(a): a = [[j for j in i if j] for (n, i) in enumerate(a) if i not in a[:n] and any(i)] for i in range(len(a)): temp1 = a[i][2].split('#')[0] temp2 = a[i][2].split('#')[1] a[i][0] = a[i][0].replace('Выполнено', 'Да') a[i][0] = a[i][0].replace('Не выполнено', 'Нет') temp3 = a[i][0] temp = a[i][1][:2] + a[i][1][4:] temp1 = temp1[temp1.find('@') + 1:] temp2 = temp2[:temp2.find('-')] + temp2[temp2.find('-') + 1:] a[i] = [temp3] + [temp] + [temp2] + [temp1] a = sorted(a, key=lambda x: x[1]) a = list(map(list, zip(*a))) return a" "def tr(data): res = [] for i in range(len(data[0])): part = [] for j in range(len(data)): part.append(data[j][i]) res.append(part[::-1]) return res def main(data1): data2 = [] for part in data1: if part not in data2 and part != [None, None, None, None, None]: data2.append(part) data2 = tr(data2) data3 = [] for part in data2: if part not in data3: data3.append(part) data3 = tr(data3) data3 = tr(data3) data3 = tr(data3) for part in data3: ch1 = part[0].split(' ') part[0] = ch1[2] + ' ' + ch1[0] part[1] = '.'.join(part[1].split('-')[::-1]) part[2] += '0' part[3] = part[3].replace('false', 'N').replace('true', 'Y') data3 = sorted(data3, key=lambda part: part[0])[::-1] return tr(data3)" "def main(x): s = [[]] for i in range(len(x) - 1): if x[i][0] is None: continue s.append([]) j = 0 for i in range(len(x)): if x[i][0] is None: continue s[j].append(x[i][0].split('|')[0].split('/')[2] + '.' + x[i][0].split('|')[0].split('/')[1] + '.' + x[i][0].split('|')[0].split('/')[0]) s[j].append(x[i][0].split('|')[1].split('.')[0].split(' ')[1] + '. ' + x[i][0].split('|')[1].split('.')[0].split(' ')[0]) s[j].append(x[i][1].split('@')[1]) j = j + 1 return s" "import re def main(x): res = x names = [] dates = [] statuses = [] for i in range(0, len(x)): if x[i][0] is not None: name = re.split(' ', x[i][3]) name = name[1] + ' ' + name[0] name = name[:len(name) - 2] date = x[i][0].replace('-', '/') if x[i][2] == 'Не выполнено': status = 'нет' else: status = 'да' res[i][0] = date res[i][1] = status res[i][2] = name del res[i][3] res.sort(key=lambda k: k[2]) return res" "def main(table): t_table = [] for a in range(len(table[0])): temp = [] for b in range(len(table)): if table[b][a] is None: continue table[b][a] = table[b][a].replace('Нет', 'N') table[b][a] = table[b][a].replace('Да', 'Y') table[b][a] = table[b][a].replace('.', '-') t_temp = table[b][a].split(' ') if len(t_temp) > 1: table[b][a] = f'{t_temp[1][:1]}. {t_temp[0]}' if a == len(table[0]) - 1: table[b][a] = f'{table[b][a][3:][:3]}-{table[b][a][6:][:2]}-{table[b][a][-2:][:2]}' temp.append(table[b][a]) if len(temp) != 0 and temp not in t_table: t_table.append(temp) return t_table" "def main(x): sp = [list(filter(lambda k: k is not None, i)) for i in x] sp = list(filter(lambda k: k != [], sp)) sp = [[i[0].split('[')[0], str(round(float(i[1].replace(',', '.')), 1)), i[0].split('!')[1].replace('.', '/')[-2:] + i[0].split('!')[1].replace('.', '/')[2:6] + i[0].split('!')[1].replace('.', '/')[:2], ''.join('(' + i[2][2:5] + ') ' + i[2][5:8] + '-' + i[2][8:12])] for i in sp] return sp" "def main(x): for i in x: for j in i: if i.count(j) > 1: i.remove(j) count = len(x) while count > 0: del x[count - 1][0] count -= 1 for i in x: date = i[0][i[0].find('#') + 1:] fio = i[0][:i[0].find('#')] i.append(date) i[0] = fio for i in x: surname = i[0][i[0].find('. ') + 2:] name = i[0][:i[0].find('.') - 2] i[0] = surname + ' ' + name i[1] = i[1].replace('@', '[at]') tmp = float(i[2]) tmp = '{:.2f}'.format(tmp) i[2] = '{:.0%}'.format(float(tmp)) i[3] = i[3].replace('.', '/') y = [] templist0 = [] templist1 = [] templist2 = [] templist3 = [] for i in x: templist3.append(i[3]) templist2.append(i[2]) templist1.append(i[1]) templist0.append(i[0]) y.append(templist0) y.append(templist3) y.append(templist1) y.append(templist2) return y" "def main(table): parsed = set() result = [] for (ready, data) in table: parsed_res = [] if data in parsed or data is None: continue email = data.split('#')[1] num = data.split('#')[0] if ready == 'Выполнено': parsed_res.append('Да') else: parsed_res.append('Нет') parsed_res.append(email.split('@')[0]) phone1 = num.replace('(', '').replace(')', '').split(' ') phone2 = phone1[1].split('-') parsed_res.append(f'{phone1[0]}-{phone2[0]}-{phone2[1]}{phone2[2]}') result.append(parsed_res) return result" "from operator import itemgetter def change(s): s[0] = s[0][:s[0].index('[')] s[1] = str(round(float(s[1]), 1)) s[2] = s[2][s[2].index('. ') + 2:] return s def new_lists(s): s = sorted(s, key=itemgetter(2)) ns1 = [] ns2 = [] ns3 = [] for s_list in s: ns1.append(s_list[0]) ns2.append(s_list[1]) ns3.append(s_list[2]) ns = [ns1, ns2, ns3] return ns def main(s): for i in range(len(s)): s[i] = change(s[i]) s = list(filter(None, s)) return new_lists(s)" "def main(table): new_table = [] for row in table: if row in table and set(row) != {''}: if row not in new_table: new_table.append(row) new_table = [] for row in table: nickname = row[0].split('@')[0] fullname = row[2].split('|')[0] letter_1 = fullname.split(' ')[1] surname = fullname.split(' ')[2] letter = row[2].split('|')[0] true_name = letter[0] + '.' + letter_1 + ' ' + surname country_code = row[2].split('|')[1][1:4] phone = country_code + '-' + row[2].split('|')[1].split(' ')[1] if [nickname, true_name, phone] not in new_table: new_table.append([nickname, true_name, phone]) new_table.sort(key=lambda x: x[1]) table = list(map(list, zip(*new_table))) return table" "def remove_duplicate_columns(table): columns_for_deletion = [] for i in range(len(table[0]) - 1): for j in range(i + 1, len(table[0])): column_i = [row[i] for row in table] column_j = [row[j] for row in table] if column_i == column_j: columns_for_deletion.append(j) return [[element for (index, element) in enumerate(row) if index not in columns_for_deletion] for row in table] def remove_duplicate_rows(table): new_table = [] for row in table: if row not in new_table and row != [None] * len(row): new_table.append(row) return new_table def reformat(table): for (i, row) in enumerate(table): for (j, element) in enumerate(row): if '0.' in element: table[i][j] = element + '000' elif '[at]' in element: table[i][j] = element[element.index('[at]') + 4:] elif '-' in element: table[i][j] = '.'.join(element.split('-')[::-1]) return table def transpose(table): return [[row[i] for row in table] for i in range(len(table[0]))] def main(table): table = remove_duplicate_columns(table) table = remove_duplicate_rows(table) table = reformat(table) table = transpose(table) return table" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result '\ndef replace(lst):\n for key, value in enumerate(lst[0]):\n lst[0][key] = ""{:.4f}"".format(float(lst[0][key]))\n for key, value in enumerate(lst[3]):\n lst[3][key] = lst[3][key].replace(\'1\', \'Выполнено\')\n lst[3][key] = lst[3][key].replace(\'0\', \'Не выполнено\')\n for key, value in enumerate(lst[2]):\n datetime_object = datetime.strptime(lst[2][key], \'%d/%m/%Y\')\n lst[2][key] = datetime_object.strftime(""%y.%m.%d"")\n for key, value in enumerate(lst[1]):\n lst[1][key] = lst[1][key].replace(\'(\', \' \')\n lst[1][key] = lst[1][key].replace(\')\', \' \')\n return lst\n' def splt(lst): for i in lst: s = i[0].split(';') i[0] = s[0] i.append(s[1]) return lst def format(lst): for i in lst: i[0] = '{:.4f}'.format(float(i[0])) i[1] = i[1].replace('@', '[at]') tel = i[2] i[2] = tel[5:][:3] + '-' + tel[8:][:2] + '-' + tel[10:][:2] return lst def main(lst): lst = transpose(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = splt(lst) lst = format(lst) return lst" "def main(table): for row in table: if row[0] == row[1]: del row[1] if row[2] == row[3]: del row[3] if row[0] is None: del row[0] row[2] = row[2].split(' ')[1] + '-' + row[2].split(' ')[2] row[0] = '{:.0%}'.format(float(row[0])) row[1] = 'нет' if row[1] == 'Нет' else 'да' t = [[0 for j in range(len(table))] for i in range(len(table[0]))] for i in range(len(table)): for j in range(len(table[0])): t[j][i] = table[i][j] return t" "def main(data): return transponse(sort(date_reformat(erase_emails(splitting_columns(delete_doubles_rows(delete_empty_columns(delete_doubles_columns(data)))))))) def delete_doubles_columns(data): columns_to_delete = [] for str in data: for el1 in range(len(str)): for el2 in range(el1, len(str)): if not el1 == el2: if str[el1] == str[el2]: if el2 not in columns_to_delete: columns_to_delete.append(el2) for j in columns_to_delete: for i in range(len(data)): _ = data[i].pop(j) return data def delete_empty_columns(data): columns_to_delete = [] rows = len(data) for el1 in range(len(data[0])): delete = True for str in data: if str[el1] is not None: delete = False break if delete: if el1 not in columns_to_delete: columns_to_delete.append(el1) for j in columns_to_delete: for i in range(rows): _ = data[i].pop(j) return data def delete_doubles_rows(data): rows_to_delete = [] for el1 in range(len(data)): for el2 in range(el1, len(data)): if not el1 == el2: if compare(data[el1], data[el2]): rows_to_delete.append(el2) for i in rows_to_delete: data.pop(i) return data def splitting_columns(data): new_data = [] * len(data) for i in range(len(data)): new_data.append([''] * (len(data[0]) + 1)) for i in range(len(data)): for j in range(len(data[i])): if data[i][j] is not None and ':' in data[i][j]: new_data[i][j] = data[i][j][data[i][j].find(':') + 1:] + '00' t = data[i][j].rfind('-') new_data[i][j + 1] = (data[i][j][3:t] + data[i][j][t + 1:data[i][j].find(':')]).replace(' ', '-') for i in range(len(data)): for j in range(1, len(data[0])): new_data[i][j + 1] = data[i][j] return new_data def erase_emails(data_): data = data_ for i in range(len(data)): for j in range(len(data[i])): if data[i][j] is not None and data[i][j].find('@') != -1: data[i][j] = data[i][j][data[i][j].find('@') + 1:] return data def date_reformat(data_): data = data_ for i in range(len(data)): for j in range(len(data[i])): if data[i][j] is not None and data[i][j].find('/') != -1: data[i][j] = data_[i][j][data_[i][j].rfind('/') + 1:] + '.' + data_[i][j][data_[i][j].find('/') + 1:data_[i][j].rfind('/')] + '.' + data_[i][j][:data_[i][j].find('/')] return data def sort(data): data.sort(key=lambda x: x[1]) return data def transponse(data): new_data = [] * len(data[0]) for i in range(len(data[0])): new_data.append([''] * len(data)) for i in range(len(data)): for j in range(len(data[0])): new_data[j][i] = data[i][j] return new_data def compare(data1, data2): eq = True for el in range(len(data1)): if not data1[el] == data2[el]: eq = False break return eq" "import math def main(table): parsed = set() (name, procent, year, res) = ([], [], [], []) for (data, percent, _, score, _) in table: if data in parsed or data is None: continue parsed.add(data) parsed_data = data.split('#') parsed_name = parsed_data[1].split(' ') name.append(f'{parsed_name[2]} {parsed_name[0][0]}.{parsed_name[1]}') procent.append(f'{str(int(round(float(percent) * 100)))}%') year.append(parsed_data[0].split('.')[2]) res.append('true' if score == 'Y' else 'false') return [name, procent, year, res]" "import re import datetime as DT def main(table): table1 = [i for i in table if i != [None, None, None, None]] for i in range(len(table1)): if table1[i][0] == '1': table1[i][0] = 'Y' if table1[i][0] == '0': table1[i][0] = 'N' table1[i][1] = re.sub('\\[at\\]\\w+\\.+\\w+', '', table1[i][1]) table1[i][2] = re.sub('\\w+\\s+\\w\\.+\\s', '', table1[i][2]) date = DT.datetime.strptime(table1[i][3], '%d-%m-%Y').date() table1[i][3] = date.strftime('%y-%m-%d') return table1" "import re def delete_rows(x): i = 0 n = len(x) while i != n: current_value = x[i][0] j = i + 1 while j != n: if x[j][0] == current_value: x.pop(j) j -= 1 n -= 1 j += 1 i += 1 return x def delete_empty_rows(x): i = 0 n = len(x) while i != n: if x[i][0] is None: x.pop(i) i -= 1 n -= 1 i += 1 return x def convert_date(x): for i in range(len(x)): for j in range(len(x[i])): if j == 0: x[i][j] = re.search('\\w+\\.\\w+', x[i][j]).group() elif j == 1: if x[i][j] == 'N': x[i][j] = '0' else: x[i][j] = '1' else: result = x[i][j].split(sep='/')[::-1] x[i][j] = '.'.join(result) return x def transpose(x): result = [] for i in range(len(x[0])): result.append([]) for j in range(len(x)): result[i].append(x[j][i]) return result def main(x): x = delete_rows(x) x = delete_empty_rows(x) x = convert_date(x) x = transpose(x) return x" "def change(s): if s[0] is not None: s[2] = str(round(float(s[0][:s[0].index('%')]) / 100, 1)) s[0] = s[0][s[0].index('@') + 1:] s[1] = s[1][:s[1].index('.') + 1] s[1] = s[1].replace(',', '') return [s[0], s[1], s[2]] def f(s): n = [] for i in s: if i not in n: n.append(i) return n def main(s): for i in range(len(s)): s[i] = change(s[i]) s = list(filter(None, s)) for in_list in s: if in_list[0] is in_list[1] is in_list[2] is None: s.remove(in_list) return f(s)" "def main(table): for row in table: del row[2] for row in table[:]: if set(row) == {None}: table.remove(row) for row in table: row[0] = row[0].replace(' ', '-') row[1] = '/'.join(row[1].split('/')[::-1]) (bval, email) = row[2].split('&') row.insert(2, ['Не выполнено', 'Выполнено'][int(bval)]) row[3] = email.split('[at]')[0] table.sort(key=lambda x: x[3]) return table" "def main(table): for line in table: (line[0], line[1]) = line[1].split('&') line[0] = line[0].replace('%', '') line[0] = str(int(line[0]) / 100) + '0' if len(line[0]) < 5: line[0] += '0' line[2] = line[2].replace('@', '[at]') line[1] = line[1][3:] word = line[2] line[2] = line[1] line[1] = word table = sorted(table, key=lambda x: x[2]) return table" "def main(table): for row in table: del row[0] new_table = list() for row in table: if row not in new_table: new_table.append(row) table = new_table for row in table: (yn, num) = row[0].split('|') row.insert(0, yn.lower()) row[1] = str(round(float(num), 1)) row[2] = '.'.join(row[2].split('-')[::-1]) table = list(map(list, zip(*table))) return table" "def main(table): for row in table: del row[2] row.insert(2, row[1]) for row in table: row[2] = row[2].replace('[at]', '@') (a, name) = row[0].split('!') row[0] = a[9:] row[1] = name.split(' ')[1] return table" "def main(table): for row in table: del row[1], row[2] new_table = list() for row in table: if row not in new_table: new_table.append(row) table = new_table for row in table: row[0] = str(round(int(row[0].replace('%', '')) / 100, 1)) fioTuple = row[1].split(' ') fioTuple[0] = fioTuple[0][0] + '.' row[1] = ' '.join([fioTuple[2], fioTuple[0]]) + fioTuple[1] vote_num = '0' (vote, email) = row[2].split('!') if vote == 'да': vote_num = '1' row[2] = email.replace('[at]', '@') row.insert(3, vote_num) return sorted(table, key=lambda x: x[1])" "def main(table): for row in table: del row[2] del row[3] new_table = list() for row in table: if row not in new_table: new_table.append(row) table = new_table for row in table: (yn, num) = row[0].split('&') row[1] = '.'.join(row[1].split('-')[::-1]) row.insert(2, yn[yn.find('[at]'):].replace('[at]', '')) row[0] = str(int(num == 'да')) row[3] = row[3][3:] row[3] = f'{row[3][:3]}-{row[3][3:5]}-{row[3][5:]}' return table" "def main(y): dat = [] dat1 = [] percent = [] name = [] yes = [] result = [] for i in y: if i not in dat1: dat1.append(i) for i in dat1: dat2 = [] for j in i: if j is not None: dat2.append(j) if len(dat2) != 0: dat.append(dat2) for i in dat: percent1 = str(int(float(i[0].split(';')[1]) * 100)) + '%' percent.append(percent1) name1 = i[1].split(' ')[2] + ' ' + i[1][0] + '.' + i[1].split(' ')[1] name.append(name1) if i[0].split(';')[0] == '1': no = 'да' yes.append(no) else: no = 'нет' yes.append(no) result.append(percent) result.append(name) result.append(yes) return result" "def main(table): for row in table: del row[1] del row[1] for row in table.copy(): if row == [None, None, None, None]: table.remove(row) for row in table: row[0] = ''.join(row[0].split('-')) row[0] = row[0][7:] (name, dom) = row[1].split('@') row[1] = name row[2] = '.'.join(row[2].split('.')[::-1]) (fam, ns) = row[3].split(',') row[3] = fam table = list(map(list, zip(*table))) return table" "def main(table): for row in table: if row == [None, None, None, None, None, None]: table.remove(row) for row in table: del row[2:4] del row[-1] new_table = list() for row in table: if row not in new_table: new_table.append(row) table = new_table for row in table: (numm, flag) = row[0].split(';') row.insert(0, 'Выполнено' if flag == 'Да' else 'Не выполнено') row[1] = str('{:.2f}'.format(float(numm))) row[2] = row[2].split('[')[0] row[3] = '(' + row[3][:3] + ') ' + row[3][3:6] + '-' + row[3][6:] (row[1], row[2], row[3]) = (row[2], row[3], row[1]) table = list(map(list, zip(*table))) return table" "def columnf(matr): temp_column = [] temp_row = [] n = [] filter_const = len(matr) for j in range(filter_const): temp_column.append(list(filter(None, matr[j]))) for i in range(len(temp_column)): if len(temp_column[i]) != 0: temp_row.append(list(filter(None, temp_column[i]))) return temp_row def main(matrix): matrix = columnf(matrix) for i in range(len(matrix)): inc = matrix[i][0].find(' ', 0, len(matrix[i][0]) - 1) if ' ' in matrix[i][0]: matrix[i][0] = matrix[i][0][:inc] for column in range(len(matrix[0])): inc = matrix[i][column].find('@', 0, len(matrix[i][column])) if '+7 ' in matrix[i][column]: matrix[i][column] = matrix[i][column][3:] matrix[i][column] = matrix[i][column][0:3] + '-' + matrix[i][column][4:7] + '-' + matrix[i][column][8:10] + matrix[i][column][11:13] if '/' in matrix[i][column]: matrix[i][column] = matrix[i][column][8:] + '/' + matrix[i][column][5:8] + matrix[i][column][2:4] if '@' in matrix[i][column]: matrix[i][column] = matrix[i][column][:inc] return matrix" "def main(table): m = [] m.append(table[0]) for row in table: if row[1] is None: del row[1] if row not in m: m.append(row) for i in range(len(m)): m[i][2] = m[i][2].replace(' ', '(', 1) m[i][2] = m[i][2].replace(' ', ')', 1) m[i][2] = m[i][2][0:13] + '-' + m[i][2][13:15] z = [[m[j][i] for j in range(len(m))] for i in range(len(m[0]))] for row in z: for i in range(len(row)): row[i] = row[i].replace('%', '') row[i] = row[i].replace('нет', 'N') row[i] = row[i].replace('да', 'Y') row[i] = row[i].replace('[at]', '@') for i in range(len(z[0])): z[0][i] = str(round(float(z[0][i]) / 100, 1)) return z" "def main(table): for col in table: del col[1] del col[4] del col[4] new_table = list() for row in table: if row[0] is not None: new_table.append(row) table = new_table for row in table: row[1] = row[1].replace('+7 ', '(').replace(' ', ') ').replace('-', ' ', 1).replace('-', '').replace(' ', '-').replace(')-', ') ') if row[0] == 'N': row[0] = 'Не выполнено' if row[0] == 'Y': row[0] = 'Выполнено' row[3] = '.'.join(row[3].split('/')[::-1]) s = row[2] s = s.split() s1 = s[0] s2 = s[1] s = s2 + ' ' + s1 row[2] = s table.sort(key=lambda row: row[1]) return table" "def f_1(flag, d): if flag: for i in range(len(d)): d[i].remove(d[i][3]) def main(x): d = x flag = True m = [] for i in range(len(x)): for j in range(i + 1, len(d)): t = d[i][2] == d[j][2] if d[i][0] == d[j][0] and d[i][1] == d[j][1] and t: m.append(j) p = x[i][0].split('|') d[i].append(x[i][1]) d[i].append(x[i][2]) d[i][1] = str('%.2f' % round(float(p[0]), 2)) d[i][0] = p[1] d[i].remove(d[i][2]) if d[i][2] != d[i][3]: flag = False k = d[i][0].split('.')[0].split(' ')[0] d[i][0] = d[i][0].split('.')[0].split(' ')[1] + '. ' + k if d[i][2] == 'Y': d[i][2] = 'да' elif d[i][2] == 'N': d[i][2] = 'нет' for i in m: d.pop(i) f_1(flag, d) return d" "def main(table): new_table = list() for row in table: if row not in new_table: new_table.append(row) if row == [None, None]: new_table.remove(row) table = new_table for row in table: (name, sername) = row[1].split(' ') row[1] = sername row[1] += ' ' row[1] += name (yn, email) = row[0].split(';') row.insert(0, yn) row[0] = '.'.join(row[0].split('-')[::-1]) without = 0 abc = '' for letter in email: if without == 1: abc += letter if letter == ']': without = 1 row[1] = abc table.sort(key=lambda x: x[2]) return table" "def main(y): del_row(y) del_col(y) del_double(y) separate(y) format(y) return y def del_row(y): i = 0 le = len(y) while i < le: check = 0 for t in range(4): if y[i][t] is None: check += 1 if check == 4: y.pop(i) i -= 1 le -= 1 i += 1 def del_col(y): d = [0, 0, 0, 0] for i in range(len(y)): for t in range(len(y[i])): if y[i][t] is None: d[t] = d[t] + 1 col = 4 i = 0 t = 0 while i < col: if d[i] == len(y): for j in range(len(y)): y[j].pop(t) col -= 1 t -= 1 i += 1 t += 1 def del_double(y): r = len(y) i = 0 while i < r - 1: j = i + 1 while j < r: if y[i] == y[j]: y.pop(j) r -= 1 j -= 1 j += 1 i += 1 def separate(y): for i in range(len(y)): w1 = y[i][0] w2 = y[i][0][y[i][0].find('|') + 1:] w1 = y[i][0][0:y[i][0].find('|')] y[i][0] = w1 y[i].append(w2) def format(y): for i in range(len(y)): y[i][0] += '00' y[i][1] = y[i][1].replace('/', '-') y[i][2] = y[i][2][:2] + '(' + y[i][2][2:5] + ')' + y[i][2][5:] y[i][2] = y[i][2][:10] + '-' + y[i][2][10:12] + '-' + y[i][2][12:]" "def main(table): for row in table: del row[1] lst = list() for row in table: if row not in lst and set(row) != {None}: lst.append(row) table = lst for row in table: if row[0] == 'Да': row[0] = 'Выполнено' else: row[0] = 'Не выполнено' (name, mail) = row[1].split(';') name = name[0] + '.' + name.split(' ', 1)[1] mail = mail.replace('@', '[at]') row[1] = mail row.insert(2, name) table = [[table[j][i] for j in range(len(table))] for i in range(len(table[0]))] return table" "def remove_same_rows_func_1(t, odds): for el in odds: while t.count(el) > 1: t.pop(len(t) - t[::-1].index(el) - 1) def remove_same_rows_func_2(t, odds, i, j): if j > i: for k in range(len(t[i])): if t[i][k] != t[j][k]: break else: odds.append(t[i]) def remove_same_rows(t): odds = [] for i in range(len(t)): for j in range(len(t)): remove_same_rows_func_2(t, odds, i, j) remove_same_rows_func_1(t, odds) def remove_same_columns_func_1(t, odds): for el in odds: for i in range(len(t)): while t[i].count(el) > 1: t[i].remove(el) def remove_same_columns_func_2(t, odds, i, j): for k in range(len(t)): if j > i and t[k][j] != t[k][i]: break else: for index in range(len(t)): odds.append(t[index][j]) def remove_same_columns(t): odds = [] for i in range(len(t[0])): for j in range(len(t[0])): remove_same_columns_func_2(t, odds, i, j) remove_same_columns_func_1(t, odds) def remove_blank_rows_func_1(t, odds): for el in odds: while el in t: t.remove(el) def remove_blank_rows(t): odds = [] for i in range(len(t)): for j in range(len(t[i])): if t[i][j] is not None: break else: odds.append(t[i]) remove_blank_rows_func_1(t, odds) def change_table(t): for ti in t: new_value_0 = 'да' if ti[2] == 'true' else 'нет' ti[2] = new_value_0 new_value_1 = ti[0][:2] + ' ' + ti[0][3:6] + ' ' + ti[0][7:13] + ti[0][14:] ti[0] = new_value_1 new_value_2 = str(round(float(ti[1]), 2)) new_value_2 += '0' * (4 - len(new_value_2)) ti[1] = new_value_2 def trans_table(t): new_t = [] for j in range(len(t[0])): new_t.append([]) for i in range(len(t)): new_t[j].append([]) for i in range(len(t)): for j in range(len(t[i])): new_t[j][i] = t[i][j] return new_t def main(t): remove_blank_rows(t) remove_same_rows(t) remove_same_columns(t) change_table(t) t = trans_table(t) return t t1 = [['+7(186)546-25-48', '0.6148', 'true', 'true'], [None, None, None, None], ['+7(120)073-19-42', '0.7217', 'false', 'false'], ['+7(790)366-40-44', '0.6920', 'true', 'true'], ['+7(790)366-40-44', '0.6920', 'true', 'true'], ['+7(790)366-40-44', '0.6920', 'true', 'true'], ['+7(072)657-17-50', '0.7039', 'false', 'false']] t2 = [[None, None, None, None], ['+7(481)972-88-03', '0.6353', 'true', 'true'], ['+7(583)277-84-81', '0.1433', 'false', 'false'], ['+7(583)277-84-81', '0.1433', 'false', 'false'], ['+7(852)446-12-55', '0.0034', 'false', 'false'], ['+7(106)937-69-57', '0.6891', 'false', 'false'], ['+7(583)277-84-81', '0.1433', 'false', 'false']]" "def main(table): for row in table: row[0] = row[0].capitalize() row[1] = str('.'.join(row[1].split('-')[::-1])) split_row = row[2].split() row[2] = split_row[0] + ' ' + split_row[2] row[3] = f'{float(row[3]):.2f}' return table" "import re def transponse(data): new_data = [] * len(data[0]) for i in range(len(data[0])): new_data.append([''] * len(data)) for i in range(len(data)): for j in range(len(data[0])): new_data[j][i] = data[i][j] return new_data def main(table): for i in range(0, len(table)): table[i].pop(1) table1 = [] for i in table: if i not in table1: table1.append(i) for i in range(len(table1)): if table[i][0] == 'N': table1[i][0] = table1[i][0].replace('N', 'false', 1) else: table1[i][0] = table1[i][0].replace('Y', 'true', 1) table1[i][1] = table1[i][1].replace('+7', '') table1[i][1] = table1[i][1].replace('-', '') prt1 = re.sub('\\(.*?\\)', string=table1[i][1], repl='') table1[i][1] = prt1 if table[i][2] == table[i][3]: table[i].pop(3) table1[i][2] = table1[i][2].replace('.', '/') table1 = transponse(table1) return table1" "def main(tab: [[str]]) -> [[str]]: result = [] for line in tab: res_line = [] number = line[1] res_line.append(number.replace(' ', '').replace('-', '')) element = line[2] if element == 'Не выполнено': res_line.append('false') elif element == 'Выполнено': res_line.append('true') date = line[3] date = date[len(date) - 2:] + '-' + date[3:5] + '-' + date[:2] res_line.append(date) name = line[4] name = name[name.find('.') + 2:] + ' ' + name[0:name.find('.') - 2] res_line.append(name) result.append(res_line) result.sort(key=lambda x: x[3], reverse=False) result = list(map(list, zip(*result))) return result" "import re def sort(data): data.sort(key=lambda x: x[2]) return data def date_reformat(data_): data = data_ for i in range(len(data)): for j in range(len(data[i])): if data[i][j] is not None and data[i][j].find('-') != -1: data[i][j] = data_[i][j][data_[i][j].rfind('-') + 1:] + '-' + data_[i][j][data_[i][j].find('-') + 1:data_[i][j].rfind('-')] + '-' + data_[i][j][:data_[i][j].find('-')] return data def main(table): for i in range(0, len(table)): table[i].pop(1) table[i].pop(1) table1 = [] for i in table: if i not in table1: table1.append(i) for i in range(len(table1)): if table[i][0] == table[i][2]: table[i].pop(2) table1[i][1] = table1[i][1].replace('.', '-') table1[i][0] = table1[i][0].replace(' ', '') table1[i][0] = table1[i][0].replace('-', '') prt1 = re.sub('\\.(\\w)', string=table1[i][2], repl='') table1[i][2] = prt1 table1 = sort(table1) table1 = date_reformat(table1) return table1" "def main(y): dat = [] dat1 = [] percent = [] mail = [] number = [] yes = [] result = [] for i in y: if i not in dat1: dat1.append(i) for i in dat1: dat2 = [] for j in i: if j is not None: dat2.append(j) if len(dat2) != 0: dat.append(dat2) for i in dat: percent1 = i[0] + '0' percent.append(percent1) mail1 = i[1].replace('@', '[at]') mail.append(mail1) number_sub = i[2].replace('+7', '') number_sub = number_sub[0] + number_sub[1] + number_sub[2] number_sub1 = i[2][5] + i[2][6] + i[2][7] number_sub2 = i[2][8] + i[2][9] + i[2][10] + i[2][11] number1 = '(' + number_sub + ') ' + number_sub1 + '-' + number_sub2 number.append(number1) if i[3] == '1': no = 'да' yes.append(no) else: no = 'нет' yes.append(no) result.append(percent) result.append(mail) result.append(number) result.append(yes) return result" "def main(table): for row in table: del row[4] for row in table[:]: if set(row) == {None}: table.remove(row) for row in table: row[0] = row[0].replace(' ', '-').strip()[4:] row[1] = row[1].strip()[5:] row[2] = row[2] + '00' row[3] = row[3].replace('Да', 'true') row[3] = row[3].replace('Нет', 'false') table.sort(key=lambda x: x[0]) return table" "def main(table): table = remove_doubles(table) edit(table) table = trans(table) return table def remove_doubles(table): new_table = [] ids = [] for row in table: if None not in row: id_ = ''.join(row) if id_ not in ids: ids.append(id_) new_table.append(row) return new_table def edit(table): for row in table: row[0] = row[0][4:].replace('-', '').replace(')', '').replace(' ', '') row[1] = f'{round(float(row[1]), 2):.2f}' row[2] = row[2].replace(',', '')[:-2] def trans(table): new_table = [] for j in range(3): row = [] for i in range(len(table)): row.append(table[i][j]) new_table.append(row) return new_table" "def convert_date(x): for i in range(len(x)): for j in range(len(x[i])): if j == 0: if x[i][j] == 'нет': x[i][j] = 'false' else: x[i][j] = 'true' elif j == 1: result = x[i][j].split(sep='/')[::-1] x[i][j] = '-'.join(result) elif j == 2: result = x[i][j].split(sep='-') x[i][j] = ''.join(result) else: result = x[i][j].split(sep=' ') x[i][j] = result[len(result) - 1] return x def main(x): x = convert_date(x) return x" "def main(data_): return transponse(reform_date(reform_name(compl_int(delete_empty_columns(delete_doubles_columns(data_)))))) def delete_doubles_columns(data_): columns_to_delete = [] for str_ in data_: for el1 in range(len(str_)): for el2 in range(el1, len(str_)): if not el1 == el2: if str_[el1] == str_[el2]: if el2 not in columns_to_delete: columns_to_delete.append(el2) for j in columns_to_delete: for i in range(len(data_)): _ = data_[i].pop(j) return data_ def delete_empty_columns(data_): columns_to_delete = [] rows = len(data_) for el1 in range(len(data_[0])): delete = True for str_ in data_: if str_[el1] is not None: delete = False break if delete: if el1 not in columns_to_delete: columns_to_delete.append(el1) for j in columns_to_delete: for i in range(rows): _ = data_[i].pop(j) return data_ def reform_date(data_): for i in range(len(data_)): for j in range(len(data_[i])): if '-' in data_[i][j]: data_[i][j] = data_[i][j][6:8] + '/' + data_[i][j][3:5] + '/' + data_[i][j][0:2] return data_ def reform_name(data_): for i in range(len(data_)): for j in range(len(data_[i])): if data_[i][j].find('.') == 1: for z in range(len(data_[i][j])): if data_[i][j][z + 4].isalpha(): data_[i][j] = data_[i][j][z + 4:] break return data_ def compl_int(data_): for i in range(len(data_)): for j in range(len(data_[i])): if data_[i][j] == 'Выполнено': data_[i][j] = '1' elif data_[i][j] == 'Не выполнено': data_[i][j] = '0' return data_ def transponse(data_): new_data = [] * len(data_[0]) for i in range(len(data_[0])): new_data.append([''] * len(data_)) for i in range(len(data_)): for j in range(len(data_[0])): new_data[j][i] = data_[i][j] return new_data" "def main(table): for row in table: del row[3] for row in table: del row[1] new_table = list() for row in table: if row not in new_table: new_table.append(row) table = new_table for i in range(0, len(table)): if table[i][0] is None: del table[i] break for row in table: (full_name, status) = row[0].split('|') row.insert(1, ('Y', 'N')[status.find(' ') != -1]) full_name_split = full_name.split(' ') full_name_split[0] = full_name_split[0].replace(full_name_split[0][1:], '.') full_name = ''.join((' '.join(full_name_split[::-2]), full_name_split[1])) row[0] = full_name row[2] = str('{:.2f}'.format(float(row[2]))) return table" "def main(s): a = [] filtred = [] r_list = [] f_list = [[], [], []] for person in s: a = list(filter(None, person)) filtred.append(a) filtred = list(filter(None, filtred)) for person in filtred: if person not in r_list: r_list.append(person) r_list = sorted(r_list, key=lambda person: person[1]) for person in r_list: fstr = person[0] fstr = fstr.replace(', ', ' ') fstr = fstr[:len(fstr) - 2] f_list[0].append(fstr) nstr = person[1] nstr = nstr[3:] f_list[1].append(nstr) dstr = person[2] dstr = dstr.replace('/', '.') dstr = dstr[6:] + dstr[2:6] + dstr[0:2] f_list[2].append(dstr) return f_list" "def main(tab0): tab1 = [] for row in tab0: if row not in tab1: tab1.append(row) tab0 = [] for row0 in tab1: row1 = row0[0].split('&') row1.append(row0[1]) row1[0] = row1[0][:2] + row1[0][4:] if row1[1] == '0': row1[1] = 'Не выполнено' else: row1[1] = 'Выполнено' row1[2] = row1[2][row1[2].find(']') + 1:] tab0.append(row1) return tab0" "import re def main(table): presort(table) A = [[], [], []] for i in range(len(table)): A = form(table[i][0], A) A = formdata(table[i][1], A) table = A return table def presort(mas): mas.sort(key=lambda temp_el: search_name(temp_el[0])) return mas def formdata(string, A): a = string[8:10] b = string[5:7] c = string[0:4] d = a + '-' + b + '-' + c A[2].append(d) return A def form(string, A): string = string.replace('-', '') A[1].append(string[3:10]) A[0].append(search_name(string)) return A def search_name(string): template = '&[a-zA-Z0-9_]+@' temp_str = re.search(template, string).group(0) return temp_str[1:len(temp_str) - 1]" "def main(table): for row in table: del row[2] for row in table: j = len(table) for row2 in table[:table.index(row):-1]: if row2 == row: del table[j - 1] j -= 1 for row in table: row.insert(0, str(round(float(row[0].replace('[at]', '@').split('&')[0]), 2))) for row in table: if len(row[0]) < 4: row[0] = row[0] + '0' for row in table: row[1] = row[1].replace('[at]', '@').split('&')[1] for row in table: row[2] = row[2][0:row[2].index(',')] return table" "def main(data): result = [] result_row = [] data = empty_matrix(data) for row in data: result_row.append(str_parse_email(row[0])) result_row.append(str_parse_name(row[1])) result_row.append(str_parse_number(row[0])) result.append(result_row) result_row = [] return result def empty_matrix(data): formatted_data = [] result_row = [] for row in data: for itr in row: if itr is None: continue result_row.append(itr) formatted_data.append(result_row) result_row = [] return formatted_data def str_parse_email(string): email = string[string.find('|') + 1:string.find('@')] return email def str_parse_number(string): number = string[string.find('('):string.find('|')] first_number = number[:12] last_number = number[13:15] number = first_number + last_number return number def str_parse_name(string): name = string[:string.find('.') + 1] return name" "def main(data): result = [] data = empty_matrix(data) data = delete_dup(data) result.append(get_dates(data)) result.append(get_domain(data)) result.append(get_percent(data)) return result def empty_matrix(data): formatted_data = [] result_row = [] for row in data: for itr in row: if itr is None: continue result_row.append(itr) formatted_data.append(result_row) result_row = [] return formatted_data def delete_dup(data): result = [] for row in data: if row not in result: result.append(row) return result def get_dates(data): result = [] for row in data: result_str = row[0][:row[0].find('!')] result_str_arr = result_str.split('-') result_str_arr.reverse() result_str = list_to_string(result_str_arr) result.append(result_str) return result def list_to_string(data): result = '' count = 0 for i in data: result += i if count is not len(data) - 1: result += '-' count += 1 return result def get_domain(data): result = [] for row in data: result_str = row[0][row[0].find(']') + 1:] result.append(result_str) return result def get_percent(data): result = [] for row in data: result_num = str(round(float(row[1]) * 100)) + '%' result.append(result_num) return result" "def main(list): list_with_email = [] for i in range(len(list)): list[i][0] = [] str3 = list[i][1] a1 = str3.index(' ') + 1 a2 = str3.index('&') str2 = str3[a1:a2] str2 = str2[:6] + '-' + str2[6:] list[i][0] = str2 list_with_email.append(list[i][2]) str3 = list[i][1] a1 = str3.index('&') + 1 str2 = str3[a1:] for j in range(len(str2)): if str2[j] == '-': str2 = str2[:j] + '.' + str2[j + 1:] temp1 = str2[:2] temp2 = str2[6:] str2 = temp2 + str2[2:6] + temp1 list[i][2] = str2 a1 = list_with_email[i].index('@') + 1 str3 = list_with_email[i][a1:] list[i][1] = str3 list[i][3] = round(float(list[i][3]), 3) list[i][3] = str(list[i][3]) if len(list[i][3]) == 4: list[i][3] = list[i][3] + '0' list.sort(key=lambda x: x[0], reverse=False) return list" "def main(x): out = [] for i in x: temp = [] for j in i: if j is not None and j.find(')') != -1: temp.append(j[j.find(')') + 1:]) elif j is not None and j.find('|') != -1: str1 = j[:j.find('|')] str2 = j[j.find('|') + 1:] tem = int(float(str2) * 100) str1 = str1.replace('-', '.') t = str(tem) + '%' temp.append(str1) temp.append(t) out.append(temp) return out" "def main(x): table = [] for i in x: i.pop(2) if i not in table and i[0] is not None: table.append(i) for i in table: i[0] = i[0][i[0].find(', ') + 2:i[0].find(', ') + 4] + ' ' + i[0][:i[0].find(',')] i[1] = i[1][-2:] + '/' + i[1][-5:-3] + '/' + i[1][:2] i[2] = i[2][:-2] + '-' + i[2][-2:] row1 = [] row2 = [] row3 = [] ex_table = [] for i in table: row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) ex_table.append(row1) ex_table.append(row2) ex_table.append(row3) return ex_table" "def main(table): indexes = [] fl = True for i in range(len(table)): for k in range(1 + i, len(table)): if table[i] == table[k]: indexes.append(k) table[i][1] = table[i][1].replace(' ', '') table[i][1] = table[i][1].replace('-', '') PercentageIndex = table[i][1].find(';') + 1 Percentage = table[i][1][PercentageIndex:len(table[i][1]) - 1] table[i][1] = table[i][1][0:len(table[i][1]) - (len(table[i][1]) - PercentageIndex + 1)] if table[i][0] == 'true': table[i][0] = 'Да' else: table[i][0] = 'Нет' email = table[i][2] address = email.find('@') + 1 email = email[address:len(email)] table[i].append(email) table[i][2] = f'{float(Percentage) / 100:.{4}f}' indexes = list(set(indexes)) if len(indexes) != 0: for i in range(len(indexes)): table.pop(indexes[i]) if i < len(indexes) - 1: indexes[i + 1] -= i + 1 result = [] k = 0 for j in range(len(table[0])): column = [] for i in range(len(table)): column.append(table[i][k]) k += 1 result.append(column) return result" "def main(inp_tbl): out_tbl = [] used_hashes = [] for (i, line) in enumerate(inp_tbl): line = [el for el in line if el] if len(line) > 0: name = line[0].split(' ') res_col = 1 if 'не выполнено' not in line[1].lower() else 0 cent = name[2].split(':') line = [f'{cent[0]} {name[0][:1]}.{name[1]}', str(res_col), format(int(cent[1][:-1]) / 100, '.4f')] row_hash = hash(tuple(line)) if row_hash not in used_hashes: used_hashes.append(row_hash) out_tbl.append(line) return out_tbl" "def change(s): for i in range(len(s)): if i > 1: s[i] = s[i].replace('(', '') s[i] = s[i].replace(') ', '-') if '%' in s[i]: s[i] = s[i].replace('%', '') s[1] = str('%.4f' % round(float(s[i][s[i].index(':') + 1:]) / 100, 4)) if s[i][13] == ':': s[i] = s[i][:10] + s[i][11:13] s = list(filter(None, s)) s[2] = s[2].rsplit('@')[0] return s def new_lists(s): ns1 = [] ns2 = [] ns3 = [] ns4 = [] for s_list in s: ns1.append(s_list[1]) ns2.append(s_list[2]) ns4.append(s_list[0]) ns = [ns4, ns1, ns2] return ns def main(s): n = [] for i in range(len(s)): s[i] = change(s[i]) if s[i] not in n: n.append(s[i]) return new_lists(n)" "import re def delete_repetitive(x): new_array = [] for row_index in range(len(x)): if x[row_index] not in new_array: new_array.append(x[row_index]) return new_array def delete_empty(x): new_array = [] for row_index in range(len(x)): if x[row_index] != [] and x[row_index] != [None, None, None, None]: new_array.append(x[row_index]) return new_array def convert(x): numbers = re.compile('([0-9]{3})([0-9]{3})([0-9]{2})([0-9]{2})') changed_nums = numbers.sub('(\\1) \\2-\\3-\\4', x[0]) names = re.compile('(?<=\\s)[А-Яа-я]+$') names_matches = names.finditer(x[1]) for match in names_matches: changed_names = match[0] changed_conditional = x[2].replace('false', 'нет').replace('true', 'да') changed_emails = x[3].replace('@', '[at]') return [changed_nums, changed_names, changed_conditional, changed_emails] def main(x): x = delete_repetitive(x) x = delete_empty(x) for row in x: x[x.index(row)] = convert(row) return x" "import math def f(asd): n = [] for i in asd: if i not in n: n.append(i) return n def f1(asd): asd = list(map(list, zip(*asd[::-1]))) n = [] for i in asd: if i not in n: n.append(i) n = list(map(list, zip(*n[::-1]))) n = list(map(list, zip(*n[::-1]))) n = list(map(list, zip(*n[::-1]))) return n def main(s): to_del = [None, None, None, None] to_del = set(to_del) for i in range(len(s) - 1, -1, -1): if to_del & set(s[i]): del s[i] for i in range(len(s)): for j in range(0, 4): if s[i][j] == '1': s[i][j] = 'да' elif s[i][j] == '0': s[i][j] = 'нет' elif '0.' in s[i][j]: s[i][j] = str(round(float(s[i][j]), 1)) elif type(s[i][j] == str): s[i][j] = s[i][j].split(' ')[1] s = f1(s) s = f(s) return s" "class Modlist: indexBad = -1 spi = [] def __init__(self, listLine): self.matrix = listLine def deleteDuplicateColumns(self): for i in range(len(self.matrix[0]) - 2): for j in range(i + 1, len(self.matrix[0])): if self.matrix[0][i] == self.matrix[0][j]: self.indexBad = j break rows = len(self.matrix) for i in range(rows): _ = self.matrix[i].pop(self.indexBad) def deleteEmptyColumns(self): self.spi = [] for i in range(len(self.matrix[0])): if self.matrix[0][i] is None: self.spi.append(i) rows = len(self.matrix) self.spi[1] -= 1 for i in range(len(self.spi)): for j in range(rows): _ = self.matrix[j].pop(self.spi[i]) def deleteDuplicateRows(self): self.spi = [] for i in range(len(self.matrix) - 2): for j in range(i + 1, len(self.matrix)): if self.matrix[i][0] == self.matrix[j][0]: self.spi.append(j) self.spi = list(set(self.spi)) for k in range(len(self.spi)): _ = self.matrix.pop(self.spi[k] - k) def normalizeData(self): for i in range(len(self.matrix)): self.matrix[i][0] = self.matrix[i][0][:len(self.matrix[i][0]) - 2] self.matrix[i][1] = ''.join(self.matrix[i][1].split(' ')) self.matrix[i][2] = self.matrix[i][2].replace('@', '[at]') def main(list1): o = Modlist(list1) o.deleteDuplicateColumns() o.deleteEmptyColumns() o.deleteDuplicateRows() o.normalizeData() return o.matrix" "def main(table): table = first(table) table = second(table) table = third(table) return table def first(table): new_table = [i for i in table if i != [None, None, None]] return new_table def second(table): for i in table: i.append(i[2]) (i[1], i[3]) = i[1].split('!') i[3] = str(int(round(float(i[3]), 2) * 100)) + '%' return table def third(table): for i in table: i[0] = '-'.join(reversed(i[0].split('.'))) list = i[1].split(', ') list[1].split('.') list = [list[1][0], list[0]] i[1] = '. '.join(list) i[2] = 'Да' if i[2] == 'Y' else 'Нет' return table" "def main(table): table = first(table) table = second(table) table = third(table) table = fourth(table) table = fifth(table) return table def first(table): for row in table: while row.count(None): row.remove(None) return table def second(table): table = [row for row in table if row != []] return table def third(table): for row in table: row.append(row[0]) (row[2], row[0]) = row[0].split(':') return table def fourth(table): for row in table: row[0] = 'Нет' if row[0] == 'нет' else 'Да' row[1] = row[1].split('[at]')[1] row[2] = '.'.join(reversed(row[2].split('.'))) return table def fifth(table): trance_table = [[table[j][i] for j in range(len(table))] for i in range(len(table[0]))] return trance_table" "import re from itertools import groupby import itertools def unique_items(x): found = set() for item in x: if len(item) > 0: if item[0] not in found: yield item found.add(item[0]) def main(x): for i in range(0, len(x)): x[i] = [k for k in x[i] if k] x = list(unique_items(x)) x = [i for i in x if i] transpoted_x = list(map(list, itertools.zip_longest(*x, fillvalue=None))) transpoted_x = [i for (i, _) in groupby(transpoted_x)] for i in range(0, len(x)): transpoted_x[0][i] = re.sub('\\[at]', '@', transpoted_x[0][i]) transpoted_x[1][i] = re.split(' ', transpoted_x[1][i])[2] transpoted_x[2][i] = re.sub('Y', 'Выполнено', transpoted_x[2][i]) transpoted_x[2][i] = re.sub('N', 'Не выполнено', transpoted_x[2][i]) transpoted_x[3][i] = re.sub('-', '/', transpoted_x[3][i]) return transpoted_x" "def main(list1): result = [] for i in list1: if i not in result: result.append(i) for i in range(0, len(result)): result[i].pop(2) a = float(result[i][2]) result[i][2] = str(round(a, 1)) result.sort(key=lambda x: x[1], reverse=False) result = list(map(list, zip(*result))) for i in range(0, len(result[0])): if result[0][i] == 'false': result[0][i] = 'Не выполнено' else: result[0][i] = 'Выполнено' for i in range(0, len(result[1])): result[1][i] = result[1][i].replace(' ', '').replace('-', '') return result" "import datetime as DT def main(book): indexForNotEmpty = -1 index = [] index1 = -1 secondUpper = 1 upperLeters = [] for i in range(0, len(book)): if book[i][0] is None: index.append(i) book.pop(index[1]) book.pop(index[0]) for i in range(0, len(book)): for j in range(0, len(book)): if book[i] == book[j] and i != j: index1 = j book[i].pop(3) date = DT.datetime.strptime(book[i][3], '%Y.%m.%d').date() book[i][3] = date.strftime('%d.%m.%Y') book[i][2] = book[i][2].replace('%', '', 1) number = round(int(book[i][2]) / 100, 1) book[i][2] = str(number) book[i][1] = book[i][1].replace(' ', '', 1) book[i][0] = book[i][0].replace('@', '[at]') book[i][1] = book[i][1].replace('.', '') spaceIndex = book[i][1].find(' ') word1 = book[i][1][:int(spaceIndex + 1)] word2 = book[i][1][int(spaceIndex):] book[i][1] = word2 + ' ' + word1 book[i][1] = book[i][1][1:-1] book[i][1] = book[i][1][:-1] book.pop(index1) return book" "def main(x): n = len(x) out = [[], [], [], []] for i in range(0, n): f = x[i][0].split(' ') out[0].append(f[2] + ', ' + f[0][0] + '.' + f[1]) out[1].append(x[i][1].replace('@', '[at]')) out[2].append(x[i][3][6:] + '.' + x[i][3][3:5] + '.' + x[i][3][:2]) out[3].append(x[i][4].capitalize()) return out" "def change(s): s = list(filter(None, s)) for i in range(len(s)): if ' ' in s[i]: s[0] = s[i][s[i].index(' ') + 1:] elif s[i].count('.') == 1: s[i] += '0' else: s[i] = s[i].replace('.', '-') s2 = [] for item in s: if item not in s2: s2.append(item) return s2 def main(s): for i in range(len(s)): s[i] = change(s[i]) s = list(filter(None, s)) s = sorted(s, key=lambda s_list: s_list[0].split()[-1]) trans_s = [[s[j][i] for j in range(len(s))] for i in range(len(s[0]))] return trans_s" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result '\ndef replace(lst):\n for key, value in enumerate(lst[0]):\n lst[0][key] = ""{:.4f}"".format(float(lst[0][key]))\n for key, value in enumerate(lst[3]):\n lst[3][key] = lst[3][key].replace(\'1\', \'Выполнено\')\n lst[3][key] = lst[3][key].replace(\'0\', \'Не выполнено\')\n for key, value in enumerate(lst[2]):\n datetime_object = datetime.strptime(lst[2][key], \'%d/%m/%Y\')\n lst[2][key] = datetime_object.strftime(""%y.%m.%d"")\n for key, value in enumerate(lst[1]):\n lst[1][key] = lst[1][key].replace(\'(\', \' \')\n lst[1][key] = lst[1][key].replace(\')\', \' \')\n return lst\n' def splt(lst): for i in lst: s = i[0].split(';') i[0] = s[1] i.insert(2, s[0]) return lst def format(lst): for i in lst: i[0] = i[0].replace('@', '[at]') v = i[1].split(' ') i[1] = v[0][:1] + '.' + v[1] + ' ' + v[2] i[2] = i[2].split(' ')[1] h = i[3].split('/') i[3] = f'{h[2]}.{h[1]}.{h[0]}' return lst def main(lst): lst = transpose(lst) lst = find_empty(lst) lst = del_empty(lst) lst = duble_delete(lst) lst = transpose(lst) lst = find_empty(lst) lst = del_empty(lst) lst = splt(lst) lst = format(lst) return lst" "def main(table): parsed = set() result = [] for (phone, _, fio, email, score) in table: (phone_parsed, full_name, domain, res_score) = ([], [], [], []) if phone in parsed or phone is None: continue parsed.add(phone) phone_parsed.append(f'+7({phone[2:5]}){phone[5:8]}-{phone[8:10]}-{phone[10:12]}') fio_parsed = fio.split(' ') full_name.append(f'{fio_parsed[0][0]}.{fio_parsed[1]} {fio_parsed[2]}') domain.append(email.split('@')[1]) res_score.append('Выполнено' if score == '1' else 'Не выполнено') result.append([phone_parsed[0], full_name[0], domain[0], res_score[0]]) return sorted(result, key=lambda x: x[0])" "def main(inp): for _ in range(0, len(inp)): inp[_] = list(dict.fromkeys(inp[_])) for _ in range(0, len(inp)): index = inp[_][0].find('&') inp[_].append(str(round(round(float(inp[_][0][:index]), 2) * 100)) + '%') inp[_][0] = inp[_][0][index + 1:inp[_][0].find('[')] index = inp[_][1].rfind('-') inp[_][1] = inp[_][1][:index] + inp[_][1][index + 1:] inp[_][2] = inp[_][2][inp[_][2].rfind(' ') + 1:] return inp" "def main(list1): result = [] for i in list1: if i not in result: result.append(i) result.remove([None, None, None]) for i in range(0, len(result)): result[i][1] = result[i][1][4:] for i in range(0, len(result)): a = result[i][0].index('.') result[i][0] = result[i][0][a + 2:] for i in range(0, len(result)): a = result[i][2].index('|') result[i].append(result[i][2][:a]) result[i][2] = result[i][2][a + 1:] if result[i][2] == 'false': result[i][2] = 'Не выполнено' else: result[i][2] = 'Выполнено' for i in range(0, len(result)): a = result[i][3] result[i][3] = str(f'{float(a):.{3}f}') return result" "def main(table1): for i in table1: match i[0]: case '0': i[0] = 'нет' case '1': i[0] = 'да' i[1] = i[1][i[1].rfind(' ') + 1:] dates = i[2].split('-') i[2] = dates[-1] + '.' + dates[1] + '.' + dates[0] phone = i[3].split() i[3] = '(' + phone[1] + ') ' + phone[2] i[3] = i[3][:-3] + i[3][-2:] return sorted(table1, key=lambda name: name[1])" "def main(array): arr1 = [] for i in array: if i not in arr1: arr1.append(i) for i in range(0, len(arr1)): str1 = arr1[i][0] temp = str1.split('/') temp.reverse() arr1[i][0] = '/'.join(temp) for i in range(0, len(arr1)): str1 = arr1[i][1] str2 = str1[2:len(str1)] str3 = str2[0:3] str3 = '(' + str3 + ')' str4 = str2[3:6] str5 = str2[6:8] str6 = str2[8:10] str7 = str3 + ' ' + str4 + '-' + str5 + '-' + str6 arr1[i][1] = str7 for i in range(0, len(arr1)): str1 = float(arr1[i][2]) arr1[i][2] = str(round(str1, 3)) if len(arr1[i][2]) < 5: arr1[i][2] = arr1[i][2] + '0' return arr1" "def main(table): table = set(map(tuple, zip(*table))) table = list(filter(lambda x: any(x), table)) def f1(a): return list(map(lambda x: x.replace('0.', '').lstrip('0') + '%', a)) def f2(a): return list(map(lambda x: x[:-4] + x[-2:], a)) def f3(a): return list(map(lambda x: x.split()[-1], a)) new_table = [None, None, None] for (i, row) in enumerate(table): if ' ' in row[0]: new_table[2] = f3(row) elif '.' in row[0]: new_table[0] = f1(row) else: new_table[1] = f2(row) table = list(map(list, zip(*new_table))) return table" "def first_step(s): flag = False for i in range(len(s[0]) - 1): for j in range(i + 1, len(s[0])): if s[0][i] == s[0][j]: flag = True for r in range(len(s)): s[r].remove(s[r][j]) break if flag: break def main(s): first_step(s) t = 1 k = 0 while k != len(s) - 1: if t == 1: t = 0 for i in range(k + 1, len(s)): if s[k][0] == s[i][0]: s.pop(i) t = 1 break elif t == 0: k += 1 t = 1 for i in range(len(s)): d = s[i][0].find(':') temp = s[i][0][d + 1:d + 5] s[i].append(0) s[i][3] = s[i][2] s[i][2] = s[i][1] s[i][1] = s[i][0][:d] s[i][0] = str(round(float(temp), 1)) r = s[i][2].find(']') s[i][2] = s[i][2][r + 1:] s[i][3] = str(bool(int(s[i][3]))).lower() s[i][1] = s[i][1][:3] + '-' + s[i][1][3:5] + '-' + s[i][1][5:] s_2 = [[], [], [], []] for i in range(4): for j in range(len(s)): s_2[i].append(s[j][i]) return s_2" "def main(table): new_table = [] set_table = [] for row in table: if row not in set_table: set_table.append(row) for row in set_table: first = row[0] second = row[1] first = first.split(';') (first[0], first[1]) = (first[1], first[0]) first[0] += '0' name = first[1] name = name.split(' ') name = name[2] + ' ' + name[0][0] + '.' + name[1] first[1] = name second = second.split('.') second = second[2] + '.' + second[1] + '.' + second[0] first.append(second) new_table.append(first) return new_table" "def main(table): new_table = [] for row in table: res = [] size = len(row) + 1 if row[0] is not None: s = row[0].split(':') m = row[1].split('@') n = s[0].split(' ') res.append(n[1] + ' ' + n[0][:2]) res.append(m[0]) res.append(str(round(int(s[1][:-1]) / 100, 1))) if row[2] == 'да': res.append('true') elif row[2] == 'нет': res.append('false') new_table.append(res) trans_table = [] for i in range(size): res = [] for row in new_table: res.append(row[i]) trans_table.append(res) return trans_table" "def main(x): x = deleteEmptyColumns(x) x = deleteEmptyStr(x) x = deleteEmptyColumns(x) x = deleteEmptyStr(x) x = transformNames(x) x = Dubs(x) x = parseFloat(x) x = changeTable(x) x = deleteEmptyStr(x) x = deleteEmptyColumns(x) return x def deleteEmptyColumns(array): for i in array: for counter in range(i.count(None)): i.remove(None) return array def deleteEmptyStr(array): for i in array: deleteFlag = True for checker in i: if checker: deleteFlag = False if deleteFlag: array.remove(i) return array def transformNames(array): index = array[1].count('true') if index == 0: num = array[1].index('false') elif index != 0: num = array[1].index('true') for i in array: if i[num].startswith('false'): i[num] = 'Не выполнено' else: i[num] = 'Выполнено' return array def Dubs(array): for i in array: for name in range(len(i)): n = i[name] n = n.replace('|', ' ') n = n.replace('@', ' @') i[name] = n return array def parseFloat(array): for i in array: d = i[0] d = d[:-1] d = d.split() i[0] = d i[0][2] = float(i[0][2]) i[0][2] = str(i[0][2] / 100) d = len(i[0][2]) if d < 4: i[0][2] = i[0][2] + '0' return array def parseNames(array): for i in array: buff = i[0].split(' ') ans = buff[0].split('.')[0] + '. ' + buff[1] i[2] = ans return array def changeTable(array): ans = [[], [], []] for i in array: ans[0].append(i[0][2]) ans[1].append(i[1]) ans[2].append(i[0][0]) k = 0 f = 0 lol = len(ans[0]) - 1 for i in range(lol + 1): for y in range(lol): if f >= lol: break if k >= lol: break if ans[2][lol] == ans[2][lol - y] and y != 0: ans[0][lol] = None ans[1][lol] = None ans[2][lol] = None if ans[2][i] == ans[2][y] and i != y: ans[0][y] = None ans[1][y] = None ans[2][y] = None return ans" "def main(table): n = len(table) k = len(table[0]) table_new = [[]] * k for i in range(k): table_new[i] = [[]] * n for i in range(0, n): for j in range(len(table[i])): if j == 0: if table[i][j][0] == 'н': table_new[1][i] = '0' table_new[0][i] = table[i][j][4:-3] + table[i][j][-2:] else: table_new[1][i] = '1' table_new[0][i] = table[i][j][3:-3] + table[i][j][-2:] if j == 2: table_new[2][i] = table[i][2][-4:] + table[i][2][2:6] + table[i][2][0:2] return table_new" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_rows(table): for i in range(len(table) - 1): for j in range(i + 1, len(table)): if table[i] == table[j]: table[j] = [None] * len(table[0]) return table def delete_duplicate_columns(table): for i in range(len(table) - 1): del table[i][2] return table def transformer(i, value): if i == 0: return f'{value[0:2]}({value[3:6]}){value[7:13]}-{value[13:15]}' if i == 1: return f'{value[6:10]}/{value[3:5]}/{value[0:2]}' if i == 2: return value[value.find('@') + 1:len(value)] if i == 3: return 'Выполнено' if value == 'Y' else 'Не выполнено' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_duplicate_columns(delete_empty_rows(delete_duplicate_rows(table)))))" "def main(data): return transponse(vot(erase_name(erase_nam(erase_emails(delete_doubles_columns(delete_empty_columns(data))))))) def delete_doubles_columns(data): columns_to_delete = [] for str in data: for el1 in range(len(str)): for el2 in range(el1, len(str)): if not el1 == el2: if str[el1] == str[el2]: if el2 not in columns_to_delete: columns_to_delete.append(el2) for j in columns_to_delete: for i in range(len(data)): _ = data[i].pop(j) return data def delete_empty_columns(data): output_data = [row for row in data if row[0] is not None] return output_data def erase_emails(data): for i in range(len(data)): for j in range(len(data[i])): if '@' in data[i][j]: stre = data[i][j].partition('@')[0] data[i][j] = stre + '[at]' + data[i][j][data[i][j].find('@') + 1:] return data def erase_nam(data): for i in range(len(data)): for j in range(len(data[i])): if '+7' in data[i][j]: str1 = data[i][j][data[i][j].find('7') + 1:] str0 = str1.partition(')') str2 = str1.partition(')')[2] str3 = str2.split('-') str0 = str0[0].replace('(', '') data[i][j] = f'({str0}) {str3[0]}-{str3[1]}{str3[2]}' return data def erase_name(data): for i in range(len(data)): for j in range(len(data[i])): if data[i][j].find(' ') != -1 and '(' not in data[i][j]: str1 = data[i][j].partition(' ')[2] str2 = data[i][j].partition('.')[0] data[i][j] = str1 + ' ' + str2 + '.' return data def vot(data): for i in range(len(data)): for j in range(len(data[i])): if data[i][j] == 'Y': data[i][j] = 'true' elif data[i][j] == 'N': data[i][j] = 'false' return data def transponse(data): new_data = [] * len(data[0]) for i in range(len(data[0])): new_data.append([''] * len(data)) for i in range(len(data)): for j in range(len(data[0])): new_data[j][i] = data[i][j] return new_data" "def main(data): names = [] dones = [] emails = [] dates = [] for row in data: if not any(row): continue name = row[0][:-2].replace(',', '') done = 'Выполнено' if int(row[1]) else 'Не выполнено' email = row[4].replace('@', '[at]') date = row[5].replace('-', '/') names.append(name) dones.append(done) emails.append(email) dates.append(date) ans = [names, dones, emails, dates] return ans" "def main(book): dates = [] index = 0 indexDog = 0 for i in range(0, len(book)): if book[i][0] is None: index = i break book.pop(index) for i in range(0, len(book)): indexDog = book[i][0].index('@') book[i][0] = book[i][0][:indexDog] book[i].pop(3) number = round(float(book[i][2]), 1) book[i][2] = str(number) dates = book[i][1].split('.') book[i][1] = dates[2] + '-' + dates[1] + '-' + dates[0] dates.clear() return book" "def main(a): for i in range(len(a)): a[i] = list(set(a[i])) a[i].remove(None) a[i] = sorted(a[i]) a = [x for x in a if x] for item in a: item[0] = f'{item[0][8:]}/{item[0][5:7]}/{item[0][:4]}' tempsplit = item[1].split('|') item.pop() item.extend(tempsplit) item[1] = item[1].split('@')[0] item[2] = item[2][5:] B = [[0] * len(a) for _ in range(len(a[0]))] for i in range(len(a)): for j in range(len(a[i])): B[j][i] = a[i][j] (B[2], B[0]) = (B[0], B[2]) return B" "def delete(matrix): for i in range(1, len(matrix)): for j in range(len(matrix[0])): if matrix[0][j] == matrix[i - 1][j] == matrix[i][j] is None: for k in range(len(matrix)): del matrix[k][j] break return matrix def clones_delete(matrix): newMatrix = [] for i in matrix: if i not in newMatrix and None not in i: newMatrix.append(i) return newMatrix def trans(matrix): trans_matrix = [[0 for j in range(len(matrix))] for i in range(len(matrix[0]))] for i in range(len(matrix)): for j in range(len(matrix[0])): trans_matrix[j][i] = matrix[i][j] return trans_matrix def main(matrix): matrix = delete(matrix) matrix = clones_delete(matrix) matrix = trans(matrix) for j in range(len(matrix[0])): a = matrix[0][j] a = a[3:] a = a[:3] + '-' + a[3:] matrix[0][j] = a matrix[1][j] += '0' matrix[2][j] = matrix[2][j].replace('[at]', '@') matrix = trans(matrix) return matrix" "def main(table): newTable = [] for i in range(len(table)): if not (table[i][0] is None and table[i][1] is None and (table[i][2] is None)): table[i][0] = str(int(float(table[i][0]) * 100)) + '%' table[i][1] = 'true' if table[i][1] == '1' else 'false' table[i][2] = table[i][2][0:table[i][2].index('@')] newTable.append(table[i]) trans = [[0 for _ in range(len(newTable))] for _ in range(len(newTable[0]))] for i in range(len(newTable)): for j in range(len(newTable[i])): trans[j][i] = newTable[i][j] return trans" "def change_list(any_list): any_list[1] = any_list[1][any_list[1].index(')') + 2:any_list[1].index('-') + 3] + '-' + any_list[1][any_list[1].index('-') + 3:] any_list[2] = any_list[2][any_list[2].index(']') + 1:] if any_list[0] == 'Выполнено': any_list[0] = '1' else: any_list[0] = '0' return any_list def main(old_list): list_without_repetitions = [] for el in old_list: if el not in list_without_repetitions: list_without_repetitions.append(el) for i in range(len(list_without_repetitions)): list_without_repetitions[i][0] = None list_without_repetitions[i] = list(filter(None, list_without_repetitions[i])) list_without_repetitions = list(filter(None, list_without_repetitions)) for i in range(len(list_without_repetitions)): list_without_repetitions[i] = change_list(list_without_repetitions[i]) new_list = [[each_list[0] for each_list in list_without_repetitions], [each_list[1] for each_list in list_without_repetitions], [each_list[2] for each_list in list_without_repetitions]] return new_list" "def main(matrix): arr = [] result = [] new_m = [] for i in matrix: if i not in new_m: new_m.append(i) for string in new_m: string[3] = string[0].split()[0] arr.append(string[3]) if string[0].split(';')[1] == 'true': string[0] = '1' else: string[0] = '0' string[1] = string[1].replace('/', '-') string[2] = string[2].split('[at]')[1] arr.sort() for i in arr: for string in new_m: if i in string: result.append(string) return result" "from tokenize import Double def main(y): y1 = [] for i in range(len(y)): if len(set(y[i])) == 3: y1.append(y[i]) y = y1 for i in range(len(y)): y[i].pop(3) for j in range(len(y[i])): if j == 0: y[i][j] = str(round(float(y[i][j]), 3)) if len(y[i][j]) != 5: while len(y[i][j]) != 5: y[i][j] = y[i][j] + '0' elif j == 1: y[i][j] = y[i][j][-4:-2] + ' ' + y[i][j][0:-6] elif j == 2: n = y[i][j][6:13] + '-' + y[i][j][-2:] y[i][j] = y[i][j][0:3] + '(' + y[i][j][3:6] + ')' + n return y" "def preprocess(obj): if obj.replace('/', '').isdigit(): return obj.replace('/', '-') elif obj.replace('.', '').isdigit(): num = str(round(float(obj), 3)) if len(num) != 5: num += '0' * (5 - len(num)) return num elif obj == 'Выполнено' or obj == 'Не выполнено': if obj == 'Выполнено': return '1' return '0' elif '@' in obj: return obj.replace('@', '[at]') else: return obj def main(lst): lst = list(map(lambda x: list(filter(None, x)), lst)) lst = list(filter(lambda x: x, lst)) del_lst = [] ind = 0 new_lst = [] for (i, lst_) in enumerate(lst): if lst_[ind] not in del_lst: try: lst_find = map(lambda x: 1 if x.find(';') != -1 else 0, lst_) lst_find = list(lst_find) ind = lst_find.index(1) del_lst.append(lst_[ind]) except ValueError: continue (obj_2, obj_1) = lst_[ind].split(';') lst_.remove(lst_[ind]) lst_.insert(1, obj_1) lst_.insert(2, obj_2) lst_ = list(map(preprocess, lst_)) new_lst.append(lst_) return new_lst" "def main(lst): for i in range(len(lst)): if lst[i][0] is not None: lst[i][0] = float(lst[i][0]) lst[i][0] = round(lst[i][0], 4) lst[i][0] = format(lst[i][0], '.4f') if lst[i][1] is not None: lst[i][1] = lst[i][1].replace('-', '') lst[i][1] = ''.join(lst[i][1].split(' ')[2:]) if lst[i][2] is not None: lst[i][2] = ''.join(lst[i][2].split('@')[:1]) new_lst = list(map(list, zip(*lst))) for i in range(len(new_lst)): new_lst[i] = [i for i in new_lst[i] if i is not None] return new_lst" "def main(a): res = list() for i in a: if i[0] is None: continue temp_num = format(float(i[1]), '.3f') i[1] = temp_num if i[2].find('@') != -1: i[2] = i[2].replace('@', '[at]') if i[0].find('Y') != -1: i[0] = i[0].replace('Y', '1') elif i[0].find('N') != -1: i[0] = i[0].replace('N', '0') if i not in res: res.append(i) return res" "def main(table): tmp_tb = [] for y in table: if y[0] is not None: t = [] for x in y: if x is not None: t.append(x) tmp_tb.append(t) for i in range(len(tmp_tb)): tmp_tb[i][1] = tmp_tb[i][1].replace('-', '.') tmp_tb[i][0] = tmp_tb[i][0].replace('@', '[at]') if tmp_tb[i][2][0] == 'н' or tmp_tb[i][2][0] == 'Н': tmp_tb[i][2] = 'Нет' else: tmp_tb[i][2] = 'Да' date = tmp_tb[i][1][8:] + tmp_tb[i][1][4:7] + '.' + tmp_tb[i][1][0:4] tmp_tb[i][1] = date tmp_tb.sort(key=lambda row: row[0]) n = [] for i in tmp_tb: if i not in n: n.append(i) return n" "def main(table): for row in table: del row[4] del row[2] for row in table: trow = row[0].split('-') row[0] = '.'.join([trow[2], trow[1], trow[0][2:]]) trow = ' ' + row[1][5:8] + '-' + row[1][8:] row[1] = row[1][:2] + ' ' + row[1][2:5] + trow row[2] += '000' return table" "def main(x): res = [] for i in range(len(x)): k1 = x[i][2].split('|')[0] s1 = k1[0:6] + '-' + k1[6:8] if x[i][3] == 'Y': s2 = 'Да' else: s2 = 'Нет' k = x[i][4].split('/') s3 = k[0] + '-' + k[1] + '-' + k[2] kn = x[i][2].split('|')[1].split(' ') s4 = kn[2] + ' ' + kn[0] cik = [s1, s2, s3, s4] res.append(cik) return res" "def main(data): ans = [] sdelano_row = [] for row in data: if not any(row) or row in sdelano_row: continue chislo = str(row[0]) + '0' mail_and_done = row[2].split(']')[1] mail = mail_and_done.split('|')[0] done = mail_and_done.split('|')[1] done = 'да' if done == 'true' else 'нет' name = ' '.join(row[4].split()[::-1]) ans.append([chislo, done, name, mail]) sdelano_row.append(row) ans.sort(key=lambda x: x[2]) trans_ans = [[], [], [], []] for i in ans: trans_ans[0].append(i[0]) trans_ans[1].append(i[1]) trans_ans[2].append(i[2]) trans_ans[3].append(i[3]) return trans_ans" "def main(table): new_table = list() for i in range(len(table[0])): col_list = list() for j in range(len(table)): col_list.append(table[j][i]) if col_list not in new_table: new_table.append(col_list) table = new_table for i in range(len(table[0])): (surname, name) = table[0][i].split(' ') new_name = name + ' ' + surname table[0][i] = new_name for i in range(len(table[1])): (d, m, y) = table[1][i].split('-') new_date = y + '/' + m + '/' + d table[1][i] = new_date for i in range(len(table[2])): table[2][i] = str.replace(table[2][i], '+7 (', '') table[2][i] = str.replace(table[2][i], ')', '') last_num = table[2][i][-2:] table[2][i] = table[2][i][:-3] + last_num for i in range(len(table[3])): table[3][i] = str('{:.2f}'.format(round(float(table[3][i]), 2))) return table" "def main(table): for row in table: del row[0] del row[0] new_tab = [[None, None, None]] for row in table: if row not in new_tab: new_tab.append(row) new_tab.pop(0) table = new_tab very_new_tab = [[], [], []] for row in table: very_new_tab[0].append(str(float(row[0][0:-1]) / 100) + '0' * (6 - len(str(float(row[0][0:-1]) / 100)))) very_new_tab[1].append('-'.join(row[1].split('.')[::-1])) r = row[2] very_new_tab[2].append('(' + r[0:3] + ') ' + r[4:]) return very_new_tab" "def main(input_table): return_table = [] filtered_table = [] for row in input_table: if row in filtered_table or None in row: continue filtered_table.append(row) for row in range(4): return_table.append([x for x in range(len(filtered_table))]) for i in range(len(filtered_table)): [date, phone_num] = filtered_table[i][0].split(';') is_completed = filtered_table[i][1] == 'да' surname = filtered_table[i][2].split(',') [day, month, year] = date.split('/') return_table[0][i] = phone_num.replace('(', ' ').replace(')', ' ') return_table[1][i] = 'Выполнено' if is_completed else 'Не выполнено' return_table[2][i] = year[2:4] + '-' + month + '-' + day return_table[3][i] = surname[0] return return_table" "def main(table): for row in table: del row[1] new_table = list() for row in table: if row not in new_table: new_table.append(row) table = new_table for row in table: row[0] = row[0].replace('@', '[at]') if row[1] == 'да': row[1] = '1' else: row[1] = '0' row[2] = str('%.2f' % round(float(row[2]), 2)) row[3] = row[3].replace(row[3][-4:], row[3][-2:]) table = list(map(list, zip(*table))) return table" "def new_lists(s): s.sort(key=lambda s: s[3]) ns1 = [] ns2 = [] ns3 = [] ns4 = [] for s_list in s: ns1.append(s_list[0]) ns2.append(s_list[1]) ns3.append(s_list[2]) ns4.append(s_list[3]) ns = [ns1, ns2, ns3, ns4] return ns def main(s): for i in range(len(s)): s[i] = list(filter(None, s[i])) if not len(s[i]) == 0: s[i][0] = s[i][0][:-2] + '-' + s[i][0][-2:] if 'true' in s[i][1]: s[i][1] = 'Y' else: s[i][1] = 'N' s[i][2] = s[i][2].replace('-', '.') a = s[i][2].split('.') a.reverse() s[i][2] = '.'.join(a) s[i][3] = s[i][3][-4:-2] + ' ' + s[i][3][:-5] else: s[i] = None s = list(filter(None, s)) return new_lists(s)" "def main(table): table = [row for (r, row) in enumerate(table) if row not in table[:r]] table = set(map(tuple, zip(*table))) table = list(filter(lambda x: any(x), table)) def f1(x): return x + '0' def f2(a): return list(map(lambda x: (x[:-4] + x[-2:]).replace('-', '/'), a)) new_table = [None, None, None] for (i, row) in enumerate(table): if '.' in row[0]: row = [[elem.split('#')[0], elem.split(']')[-1]] for elem in row] new_table[1] = [f1(elem[0]) for elem in row] new_table[0] = [elem[1] for elem in row] else: new_table[2] = f2(row) return new_table" "def transpose(table): new_table = [] for i in range(len(table[0])): line = [] for j in range(len(table)): line.append(table[j][i]) new_table.append(line) return new_table def remove_repeating_rows(table): new_table = [] for i in range(len(table)): if table[i] not in new_table and table[i] != [None] * len(table[i]): new_table.append(table[i]) return new_table def remove_empty_rows(table): new_table = [] for i in range(len(table)): if table[i] != [None] * len(table[i]): new_table.append(table[i]) return new_table def divide_column_by_symbol(table): for i in range(len(table)): (x, y) = table[i][-1].split('&') table[i][-1] = y table[i].insert(1, x) return table def edit_mail(table): for i in range(len(table)): table[i][0] = table[i][0].split('[at]')[-1] return table def edit_numbers(table): for i in range(len(table)): numbers = table[i][-2] table[i][-2] = '(' + numbers[:3] + ') ' + numbers[3:6] + '-' + numbers[6:] table[i][-1] = str(int(round(float(table[i][-1]), 2) * 100)) + '%' return table def main(table): table = transpose(remove_repeating_rows(transpose(table))) table = remove_empty_rows(table) table = divide_column_by_symbol(table) table = edit_mail(table) table = edit_numbers(table) table = transpose(table) return table" "def main(table): z = [] new_table = [[j for j in i if not j is None] for i in table] for i in range(len(new_table)): if len(new_table[i]) != 0: z.append(new_table[i]) super_new = [] mega_new = [] for i in z: i_00 = '.'.join(reversed(i[0].split('-'))) i_1 = i[1].split(',') x = i_1[1].strip()[:2] x1 = i_1[0] + ' ' + x i_2 = i[2].split() i_2_2 = i_2[1][:6] i_2_3 = i_2[1][6:8] x2 = i_2_2 + '-' + i_2_3 super_new.append([i_00, x1, x2, i[3].capitalize()]) for i in super_new: if i not in mega_new: mega_new.append(i) return mega_new" "def main(table): result = [] for row in table: if row[0] is None: continue tempRow = [] firstCol = row[0][16:].split('-') tempRow.append(firstCol[2] + '/' + firstCol[1] + '/' + firstCol[0]) tempRow.append(row[2][row[2].find('[at]') + 4:]) tempRow.append(row[0][3:15].replace(' ', '-')) if row[4] == 'Выполнено' and row[4] == row[3]: tempRow.append('да') else: tempRow.append('нет') result.append(tempRow) for i in range(1, len(result)): for j in range(0, len(result) - 1): if result[i][2] < result[j][2]: a = result[i] result[i] = result[j] result[j] = a return result" "def delDublicates(data): result = [] for i in data: temp = [] for j in i: if j not in temp: temp.append(j) result.append(temp) return result def separate(list): finResult = [] for el in list: result = [] for i in el: if '|' in i: first = i.split('|')[0] second = i.split('|')[1] result.append(first) result.append(second) else: result.append(i) finResult.append(result) return finResult def refactor(list): for i in range(len(list)): if list[i][0] is not None: list[i][0] = str(list[i][0]).split('@')[1] if list[i][1] is not None: list[i][1] = float(list[i][1]) list[i][1] = round(list[i][1], 4) list[i][1] = format(list[i][1], '.4f') if list[i][2] is not None: list[i][2] = str(list[i][2]).replace('/', '.') if list[i][3] is not None: list[i][3] = str(list[i][3])[:-2] list[i][3] = str(list[i][3]).replace(',', '') return list def replace(list): result = [] for el in list: temp = el[1] el[1] = el[2] el[2] = temp result.append(el) return result def main(list): result = delDublicates(list) result = separate(result) result = refactor(result) result = replace(result) return result" "def main(tabl): newtabl = [] promtabl = [] for i in range(len(tabl)): promtabl.append(funcNames(tabl[i][0])) promtabl.append(funcBoolean(tabl[i][0])) promtabl.append(funcCallNumber(tabl[i][1])) newtabl.insert(0, promtabl) promtabl = [] newtabl1 = [] for x in newtabl: if newtabl.count(x) > 1: newtabl.remove(x) for x in newtabl: newtabl1.insert(0, x) return newtabl1 def funcNames(oldFormat): x = oldFormat.split(' ') newformat = x[1] return newformat def funcBoolean(oldFormat): x = oldFormat.split(' ') x2 = x[0][0] + x[0][1] + x[0][2] if x2 == 'Нет': return 'Не выполнено' else: return 'Выполнено' def funcCallNumber(oldFormat): x = int(oldFormat[:len(oldFormat) - 1]) newformat = x / 100 newformat = '{:.3f}'.format(newformat) return newformat" "def main(table): parsed = set() result = [] for (_, phone, email, _, full_name) in table: (p_phone, p_email, p_name) = ([], [], []) if phone in parsed or phone is None: continue parsed.add(phone) p_phone.append(phone[3:]) p_email.append(email.split('[at]')[0]) p_name_split = full_name.split(' ') p_name.append(f""{p_name_split[1]} {p_name_split[0].split('.')[0]}."") result.append([p_phone[0], p_email[0], p_name[0]]) return result" "def main(data): data = [list(filter(None, row)) for row in data] data = list(filter(None, data)) for row in data: for i in range(len(row)): if row[i] == 'Нет': row[i] = 'false' elif row[i] == 'Да': row[i] = 'true' elif row[i].replace('.', '').isdigit(): row[i] = str(round(float(row[i]), 1)) elif row[i].find('@') != -1: row[i] = row[i].split('@')[0] return data" "import collections import re class table(object): def __init__(self, x): self.x = x def remove_double_none(self): for i in range(len(self.x)): n = [] for j in self.x[i]: if j not in n: n.append(j) self.x[i] = n self.x[i] = [s for s in self.x[i] if s is not None] return None '\n def remove_double_rows(self):\n for i in range(len(self.x) - 1):\n for j in range(i + 1, len(self.x)):\n if self.x[i] == self.x[j]:\n self.x.pop(j)\n if len(self.x) <= j:\n break\n return None\n ' def remove_double_rows(self): sup = [] for i in self.x: if i not in sup: sup.append(i) self.x = sup def metamorphosis(self): for i in range(len(self.x)): self.x[i][0] = str(round(float(self.x[i][0]), 1)) self.x[i][1] = self.x[i][1][2:] self.x[i][1] = '.'.join([self.x[i][1].split('-')][0][::-1]) self.x[i][2] = re.search('[А-Яа-я]+,', self.x[i][2]).group()[:-1] self.x[i][3] = ''.join(''.join(self.x[i][3].split(' ')).split('-')) return None def transpose(self): self.x = [list(s) for s in zip(*self.x)] return None def main(x): b = table(x) b.remove_double_none() b.remove_double_rows() b.metamorphosis() b.transpose() return b.x" "def main(*args): unzip = [*args] data = [x for i in unzip for x in i] new_table = [] row1 = [] row2 = [] row3 = [] tpls = [tuple(x) for x in data] dct = list(dict.fromkeys(tpls)) data = [list(x) for x in dct] for i in data: i.pop(-1) split = i[0].split('!') i.append(i[0]) i.append(i[1]) if split[1] == '0.00': split[1] = split[1].replace('.00', '') elif split[1][-2:] == '00': split[1] = split[1].replace('.', '') elif split[1][0:3] == '0.0': split[1] = split[1].replace('0.0', '') else: split[1] = split[1].replace('0.', '') split[1] = split[1][0:] + '%' i[0] = split[1] i[1] = i[2][:-7].replace(',', '') i.pop(2) i[2] = i[2][-2:] + i[2][2:6] + i[2][0:2] row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) new_table.append(row1) new_table.append(row2) new_table.append(row3) return new_table" "import re from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] new_table = [] row1 = [] row2 = [] row3 = [] row4 = [] tpls = [tuple(x) for x in data] dct = list(dict.fromkeys(tpls)) data = [list(x) for x in dct] for i in data: if i[0] is None: data.remove(i) for i in data: i.pop(3) if i[0] == 'Не выполнено': i[0] = 'нет' else: i[0] = 'да' date = datetime.strptime(i[1], '%d/%m/%Y') i[1] = date.strftime('%d.%m.%Y') i[2] = re.sub('@', '[at]', i[2]) i[3] = i[3][4:].replace('-', '') row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) row4.append(i[3]) new_table.append(row1) new_table.append(row2) new_table.append(row3) new_table.append(row4) return new_table" "def none_filter(val): return val is not None def main(input_table): return_table = [] filtered_table = [] for row in input_table: row.pop(-1) row = list(filter(none_filter, row)) if row in filtered_table: continue filtered_table.append(row) filtered_table = list(filtered_table) for i in range(len(filtered_table)): row = [] num = '{:.4f}'.format(float(filtered_table[i][0])) surname = filtered_table[i][1].split(' ')[1] row.append(num) row.append(surname) row.append('true' if filtered_table[i][2] == 'Да' else 'false') return_table.append(row) return return_table" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result '\ndef replace(lst):\n for key, value in enumerate(lst[0]):\n lst[0][key] = ""{:.4f}"".format(float(lst[0][key]))\n for key, value in enumerate(lst[3]):\n lst[3][key] = lst[3][key].replace(\'1\', \'Выполнено\')\n lst[3][key] = lst[3][key].replace(\'0\', \'Не выполнено\')\n for key, value in enumerate(lst[2]):\n datetime_object = datetime.strptime(lst[2][key], \'%d/%m/%Y\')\n lst[2][key] = datetime_object.strftime(""%y.%m.%d"")\n for key, value in enumerate(lst[1]):\n lst[1][key] = lst[1][key].replace(\'(\', \' \')\n lst[1][key] = lst[1][key].replace(\')\', \' \')\n return lst\n' def splt(lst): for i in lst: s = i[0].split(';') i[0] = s[1] i.insert(2, s[0]) return lst def format(lst): for i in lst: i[0] = i[0].replace('@', '[at]') v = i[1].split(' ') i[1] = v[0][:1] + '. ' + v[1] + ' ' + v[2] i[2] = i[2].split(' ')[1] h = i[3].split('/') i[3] = f'{h[2]}.{h[1]}.{h[0]}' return lst def sor(lst): kdf = lst kdf.sort(key=lambda x: [1]) lst = kdf return lst def format(lst): for i in lst: i[0] = i[0].replace('0', 'Не выполнено') i[0] = i[0].replace('1', 'Выполнено') i[1] = i[1].split(' ')[0] h = i[2].split('-') i[2] = f'{h[0][2:]}.{h[1]}.{h[2]}' m = i[3].split('-') i[3] = f'{m[0]}-{m[1]}{m[2]}' return lst def main(lst): lst = duble_delete(lst) lst = format(lst) lst.sort(key=lambda x: x[1]) return lst" "def clones_delete(matrix): new_matrix = [] for i in matrix: if i not in new_matrix and None not in i: new_matrix.append(i) return new_matrix def trans(matrix): trans_matrix = [[0 for j in range(len(matrix))] for i in range(len(matrix[0]))] for i in range(len(matrix)): for j in range(len(matrix[0])): trans_matrix[j][i] = matrix[i][j] return trans_matrix def main(matrix): matrix = clones_delete(matrix) matrix = trans(matrix) matrix = clones_delete(matrix) for j in range(len(matrix[0])): if matrix[0][j] == 'false': matrix[0][j] = 'Нет' else: matrix[0][j] = 'Да' a = matrix[1][j].split('/') b = a[2] + '-' + a[1] + '-' + a[0] matrix[1][j] = b c = matrix[2][j].split(',') matrix[2][j] = c[0] matrix = trans(matrix) def custom_key(matrix): return matrix[2] matrix.sort(key=custom_key) return trans(matrix)" "def main(table): res = list() tmp1 = list() for i in table: s = i[0][i[0].find('!') + 1:].replace('[at]', '@') if s not in tmp1: tmp1.append(s) else: i[0] = None i[1] = None i[2] = None res.append(tmp1) tmp2 = list() for i in table: if i[0] is not None: tmp2.append(i[0][:i[0].find('!')].replace('/', '-')) res.append(tmp2) tmp3 = list() for i in table: if i[1] is not None: tmp3.append(str(round(float(i[1]), 1))) res.append(tmp3) return res" "def main(tbl): to_pop = [] result = [] for i in range(len(tbl)): if tbl[i] == [None] * 3: to_pop.append(i) continue for m in range(i + 1, len(tbl)): if tbl[i] == tbl[m]: to_pop.append(m) for i in range(len(tbl)): if i not in to_pop: result.append(tbl[i]) for i in range(len(result)): tof = 'true' if result[i][0] == 'Y' else 'false' kega = result[i][1].split('#') num = str(round(float(kega[1]), 1)) initials = kega[0][:2] + kega[0][4:] milo = result[i][2].split('@')[1] result[i] = [tof, num, initials, milo] return result" "def myFunc(e): return e[2] def main(input_table): for i in range(0, len(input_table)): input_table[i].pop(0) return_table = [] filtered_table = [] filtered_table2 = [] for row in input_table: if row in filtered_table or None in row: continue filtered_table.append(row) for i in range(len(filtered_table)): row = filtered_table[i] [surname, name] = row[2].split(' ') row[2] = name[0:2] + ' ' + surname filtered_table2.append(row) filtered_table2.sort(key=myFunc) for row in range(4): return_table.append([x for x in range(len(filtered_table2))]) for i in range(len(filtered_table2)): phone_num = filtered_table2[i][0] is_completed = 'true' if filtered_table2[i][1] == 'Да' else 'false' [email, domain] = filtered_table2[i][3].split('@') return_table[0][i] = '%s %s %s-%s-%s' % (phone_num[0:2], phone_num[2:5], phone_num[5:8], phone_num[8:10], phone_num[10:12]) return_table[1][i] = is_completed return_table[2][i] = filtered_table2[i][2] return_table[3][i] = domain return return_table" "import copy def delete_duplicate(table): result = [] line = [] for i in range(len(table)): for j in range(len(table[i])): if table[i][j] != table[i][j - 1]: line.append(table[i][j]) result.append(line) line = [] return result def delete_empty_rows(table): result = [] line = [] for i in range(len(table)): for j in range(len(table[i])): if table[i][j] is None: line = [] else: line.append(table[i][j]) if line != []: result.append(line) line = [] return result def split_column(table): result = [] line = [] for i in range(len(table)): for j in range(len(table[i])): if '&' in table[i][j]: items = table[i][j].split('&') line.append(items[0]) line.append(items[1]) else: line.append(table[i][j]) result.append(line) line = [] return result def convert_cells(table): line = [] result = [] for i in range(len(table)): for j in range(len(table[i])): if j == 0: str = copy.copy(table[i][j]) items = str.split(' ') table[i][j] = items[2] + ' ' + items[0] if j == 1: str = copy.copy(table[i][j]) items = str.split('@') table[i][j] = items[1] if j == 2: table[i][j] = table[i][j].replace('+7', '') (table[i][j - 1], table[i][j]) = (table[i][j], table[i][j - 1]) return table def transpose(table): result = [] for i in range(len(table[0])): result.append([]) for j in range(len(table)): result[i].append(table[j][i]) return result def main(table): return transpose(convert_cells(split_column(delete_empty_rows(delete_duplicate(table)))))" "def main(s): new_list = [] for i in range(len(s)): if s[i] not in new_list: new_list.append(s[i]) for j in range(len(new_list)): new_list[j][0] = '{:.0f}'.format(float(new_list[j][0]) * 100) + '%' new_list[j][1] = new_list[j][1][1:4] + new_list[j][1][6:9] + new_list[j][1][10:] new_list[j][2] = new_list[j][2][:new_list[j][2].find('@')] return new_list" "from operator import itemgetter def main(table): parsed = set() (date, flag, pnumber, name) = ([], [], [], []) for (dateb, flag1, pnumberb, column1, flag2, column2, nameb) in table: if pnumberb in parsed: continue parsed.add(pnumberb) date.append(f'{dateb[2:4]}.{dateb[5:7]}.{dateb[8:10]}') flag.append('Выполнено' if flag1 == 'true' else 'Не выполнено') pnumber.append(f'({pnumberb[2:5]}) {pnumberb[5:8]}-{pnumberb[8:10]}-{pnumberb[10:12]}') name.append(nameb.split(' ')[0][:1] + '.' + nameb.split(' ')[1] + ' ' + nameb.split(' ')[2]) return sorted([[date[i], flag[i], pnumber[i], name[i]] for i in range(0, len(date))], key=itemgetter(3))" "import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] new_table = [] row1 = [] row2 = [] row3 = [] row4 = [] for i in data: i.pop(-1) i[0] = re.sub('@.*', '', i[0]) i[1] = i[1].replace('+7', '').replace('(', '').replace(')', '') i[1] = i[1][1:11] + i[1][12:] if i[2] == '0.00': i[2] = i[2].replace('.00', '') elif i[2][-2:] == '00': i[2] = i[2].replace('.', '') elif i[2][0:3] == '0.0': i[2] = i[2].replace('0.0', '') else: i[2] = i[2].replace('0.', '') i[2] = i[2][0:] + '%' split = i[3].split(' ') i[3] = split[1] + ' ' + split[0] row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) row4.append(i[3]) new_table.append(row1) new_table.append(row2) new_table.append(row3) new_table.append(row4) return data" "import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[2] is not None] data = [list(x) for x in tpls] new_table = [] row1 = [] row2 = [] row3 = [] row4 = [] for i in data: i.pop(0) i[0] = i[0][:-2] split = i[0].split(' ') i[0] = split[1] + ' ' + split[0] i[1] = i[1].replace('(', '').replace(')', '') i[1] = i[1][2:5] + '-' + i[1][5:11] + i[1][12:] split = i[2].split(';') if split[1] == 'Нет': i[2] = 'Не выполнено' else: i[2] = 'Выполнено' i.append(split[0] + '00') row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) row4.append(i[3]) new_table.append(row1) new_table.append(row2) new_table.append(row3) new_table.append(row4) return new_table" "def main(s): none_index_array = [] for i in range(len(s)): s[i].pop(1) s[i].remove(None) if s[i][0] is None: none_index_array.append(i) for i in range(0, len(none_index_array)): s.pop(none_index_array[i] - i) for i in range(0, len(s)): s[i][0] += '0' s[i][1] = s[i][1][0:s[i][1].find(',')] s[i][2] = s[i][2].replace('-', '.') s[i][3] = s[i][3][3:16] s[i][3] = s[i][3].replace(' ', '-') s[i][3] = s[i][3][0:10] + s[i][3][11:16] transposed_s = [[0 for j in range(len(s))] for i in range(len(s[0]))] for i in range(len(s)): for j in range(len(s[0])): transposed_s[j][i] = s[i][j] return transposed_s" "def del_row(s): s1 = [] for row in s: if row not in s1: s1.append(row) return s1 def del_col(s): for row in s: del row[2] return s def main(s): s = [row for row in s if row[0] is not None] s = del_row(s) s = del_col(s) for row in s: f = row[0].split(' ')[2] f1 = f.split('!') f1[1] = f1[1].replace('-', ') ', 1) row[0] = f1[0] row.insert(1, '(' + f1[1]) for row in s: row[2] = '{:.4f}'.format(float(row[2])) return s" "def main(*args): unzip = [*args] data = [x for i in unzip for x in i] new_table = [] tpls = [tuple(x) for x in data] dct = list(dict.fromkeys(tpls)) data = [list(x) for x in dct] for i in data: i.pop(2) i[0] = i[0].replace(',', '') i[0] = i[0][:-2] split = i[0].split(' ') i[0] = split[1] + ' ' + split[0] i[1] = i[1].replace('(', '').replace(')', '').replace('+7', '') i[1] = i[1][:3] + ' ' + i[1][3:-3] + i[1][-2:] i[2] = i[2] + '0' if i[3] == '1': i[3] = 'true' else: i[3] = 'false' row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) row.append(i[3]) new_table.append(row) new_table.sort() return new_table" "def del_row(s): s1 = [] for row in s: if row not in s1: s1.append(row) return s1 def transpose(s): s1 = [] for i in range(len(s[0])): s1.append([]) for j in range(len(s)): s1[i].append(s[j][i]) return s1 def main(s): s = [row for row in s if row[0] is not None] s = del_row(s) for row in s: row[1] = str(round(float(row[1]), 1)) if row[2] == 'true': row[2] = 'Да' else: row[2] = 'Нет' s = transpose(s) counter = 0 for x in s[0]: s[0][counter] = x.split(']')[1] counter += 1 return s" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[2] is not None] data = [list(x) for x in tpls] for i in data: i.pop(3) i[0] = i[0] + '00' i[1] = i[1][6:9] + i[1][10:12] + i[1][13:] date = datetime.strptime(i[2], '%y/%m/%d') i[2] = date.strftime('%d-%m-%y') split = i[3].split(' ') i[3] = split[1] + ' ' + split[0] return data" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result '\ndef replace(lst):\n for key, value in enumerate(lst[0]):\n lst[0][key] = ""{:.4f}"".format(float(lst[0][key]))\n for key, value in enumerate(lst[3]):\n lst[3][key] = lst[3][key].replace(\'1\', \'Выполнено\')\n lst[3][key] = lst[3][key].replace(\'0\', \'Не выполнено\')\n for key, value in enumerate(lst[2]):\n datetime_object = datetime.strptime(lst[2][key], \'%d/%m/%Y\')\n lst[2][key] = datetime_object.strftime(""%y.%m.%d"")\n for key, value in enumerate(lst[1]):\n lst[1][key] = lst[1][key].replace(\'(\', \' \')\n lst[1][key] = lst[1][key].replace(\')\', \' \')\n return lst\n' def splt(lst): for i in lst: s = i[0].split(';') i[0] = s[1] i.insert(2, s[0]) return lst def format(lst): for i in lst: i[0] = i[0].replace('@', '[at]') v = i[1].split(' ') i[1] = v[0][:1] + '. ' + v[1] + ' ' + v[2] i[2] = i[2].split(' ')[1] h = i[3].split('/') i[3] = f'{h[2]}.{h[1]}.{h[0]}' return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format(lst): for i in lst: i[0] = i[0].replace('0', 'Не выполнено') i[0] = i[0].replace('1', 'Выполнено') i[1] = i[1].split(' ')[0] h = i[2].split('-') i[2] = f'{h[0][2:]}.{h[1]}.{h[2]}' m = i[3].split('-') i[3] = f'{m[0]}-{m[1]}{m[2]}' return lst def format(lst): for i in lst: i[0] = i[0].replace('-', '') i[1] = i[1].replace('-', '/') m = i[2].split(' ') i[2] = f'{m[0][:1]}.{m[1]} {m[2]}' return lst def main(lst): lst = transpose(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = format(lst) lst.sort(key=lambda x: x[2]) lst = transpose(lst) return lst" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result '\ndef replace(lst):\n for key, value in enumerate(lst[0]):\n lst[0][key] = ""{:.4f}"".format(float(lst[0][key]))\n for key, value in enumerate(lst[3]):\n lst[3][key] = lst[3][key].replace(\'1\', \'Выполнено\')\n lst[3][key] = lst[3][key].replace(\'0\', \'Не выполнено\')\n for key, value in enumerate(lst[2]):\n datetime_object = datetime.strptime(lst[2][key], \'%d/%m/%Y\')\n lst[2][key] = datetime_object.strftime(""%y.%m.%d"")\n for key, value in enumerate(lst[1]):\n lst[1][key] = lst[1][key].replace(\'(\', \' \')\n lst[1][key] = lst[1][key].replace(\')\', \' \')\n return lst\n' def splt(lst): for i in lst: s = i[0].split(';') i[0] = s[1] i.insert(2, s[0]) return lst def format(lst): for i in lst: i[0] = i[0].replace('@', '[at]') v = i[1].split(' ') i[1] = v[0][:1] + '. ' + v[1] + ' ' + v[2] i[2] = i[2].split(' ')[1] h = i[3].split('/') i[3] = f'{h[2]}.{h[1]}.{h[0]}' return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format(lst): for i in lst: i[0] = i[0].replace('0', 'Не выполнено') i[0] = i[0].replace('1', 'Выполнено') i[1] = i[1].split(' ')[0] h = i[2].split('-') i[2] = f'{h[0][2:]}.{h[1]}.{h[2]}' m = i[3].split('-') i[3] = f'{m[0]}-{m[1]}{m[2]}' return lst def format(lst): for i in lst: m = i[2].split('.') i[2] = f'{m[2]}.{m[1]}.{m[0]}' i[3] = f'{i[3][:3]} {i[3][3:6]}-{i[3][6:10]}' i[1] = i[1] + '0' n = i[0].split(' ') i[0] = n[0] + ' ' + n[2] return lst def main(lst): lst = find_empty(lst) lst = del_empty(lst) lst = format(lst) lst = transpose(lst) return lst" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result '\ndef replace(lst):\n for key, value in enumerate(lst[0]):\n lst[0][key] = ""{:.4f}"".format(float(lst[0][key]))\n for key, value in enumerate(lst[3]):\n lst[3][key] = lst[3][key].replace(\'1\', \'Выполнено\')\n lst[3][key] = lst[3][key].replace(\'0\', \'Не выполнено\')\n for key, value in enumerate(lst[2]):\n datetime_object = datetime.strptime(lst[2][key], \'%d/%m/%Y\')\n lst[2][key] = datetime_object.strftime(""%y.%m.%d"")\n for key, value in enumerate(lst[1]):\n lst[1][key] = lst[1][key].replace(\'(\', \' \')\n lst[1][key] = lst[1][key].replace(\')\', \' \')\n return lst\n' def splt(lst): for i in lst: s = i[0].split(';') i[0] = s[1] i.insert(2, s[0]) return lst def format(lst): for i in lst: i[0] = i[0].replace('@', '[at]') v = i[1].split(' ') i[1] = v[0][:1] + '. ' + v[1] + ' ' + v[2] i[2] = i[2].split(' ')[1] h = i[3].split('/') i[3] = f'{h[2]}.{h[1]}.{h[0]}' return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format(lst): for i in lst: i[0] = i[0].replace('0', 'Не выполнено') i[0] = i[0].replace('1', 'Выполнено') i[1] = i[1].split(' ')[0] h = i[2].split('-') i[2] = f'{h[0][2:]}.{h[1]}.{h[2]}' m = i[3].split('-') i[3] = f'{m[0]}-{m[1]}{m[2]}' return lst def format(lst): for i in lst: n = i[0].split(' ') i[0] = n[1] + ' ' + n[0] i[1] = i[1].split('@')[0] i[2] = i[2].replace('N', 'Не выполнено') i[2] = i[2].replace('Y', 'Выполнено') return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = format(lst) lst.sort(key=lambda x: x[1]) lst = transpose(lst) return lst" "def del_row_dup(table): unique_table = [] for row in table: if row not in unique_table: unique_table.append(row) return unique_table def transpose(table): transposed_table = [] for i in range(0, len(table[0])): row = [] for j in range(0, len(table)): row.append(table[j][i]) transposed_table.append(row) return transposed_table def main(table): COMPLETED = 'Выполнено' NOT_COMPLETED = 'Не выполнено' transp_table = transpose(table) cleaned_column_transposed_table = del_row_dup(transp_table) cleaned_column_table = transpose(cleaned_column_transposed_table) cleaned_table = del_row_dup(cleaned_column_table) required_table = transpose(cleaned_table) for i in range(len(required_table[0])): if required_table[0][i] == 'Да': required_table[0][i] = COMPLETED else: required_table[0][i] = NOT_COMPLETED for i in range(len(required_table[1])): pn = required_table[1][i] pn = pn[:2] + ' ' + pn[2:5] + ' ' + pn[5:8] + '-' + pn[8:10] + '-' + pn[10:] required_table[1][i] = pn for i in range(len(required_table[2])): required_table[2][i] = str(int(float(required_table[2][i]) * 100)) + '%' for i in range(len(required_table[3])): required_table[3][i] = required_table[3][i][required_table[3][i].find('@') + 1:] return required_table" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result '\ndef replace(lst):\n for key, value in enumerate(lst[0]):\n lst[0][key] = ""{:.4f}"".format(float(lst[0][key]))\n for key, value in enumerate(lst[3]):\n lst[3][key] = lst[3][key].replace(\'1\', \'Выполнено\')\n lst[3][key] = lst[3][key].replace(\'0\', \'Не выполнено\')\n for key, value in enumerate(lst[2]):\n datetime_object = datetime.strptime(lst[2][key], \'%d/%m/%Y\')\n lst[2][key] = datetime_object.strftime(""%y.%m.%d"")\n for key, value in enumerate(lst[1]):\n lst[1][key] = lst[1][key].replace(\'(\', \' \')\n lst[1][key] = lst[1][key].replace(\')\', \' \')\n return lst\n' def splt(lst): for i in lst: s = i[0].split(';') i[0] = s[1] i.insert(2, s[0]) return lst def format(lst): for i in lst: i[0] = i[0].replace('@', '[at]') v = i[1].split(' ') i[1] = v[0][:1] + '. ' + v[1] + ' ' + v[2] i[2] = i[2].split(' ')[1] h = i[3].split('/') i[3] = f'{h[2]}.{h[1]}.{h[0]}' return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format(lst): for i in lst: i[0] = i[0].replace('0', 'Не выполнено') i[0] = i[0].replace('1', 'Выполнено') i[1] = i[1].split(' ')[0] h = i[2].split('-') i[2] = f'{h[0][2:]}.{h[1]}.{h[2]}' m = i[3].split('-') i[3] = f'{m[0]}-{m[1]}{m[2]}' return lst def format(lst): for i in lst: n = i[1].split('.') i[1] = f'{n[2][2:]}.{n[1]}.{n[0]}' p = i[0].split(';') i[0] = p[0] i[2] = i[2].split('@')[1] i.insert(0, p[1]) i[0] = str(int(float(i[0]) * 100)) + '%' i[1] = i[1].replace('Да', 'true') i[1] = i[1].replace('Нет', 'false') return lst def main(lst): lst = transpose(lst) lst = duble_delete(lst) lst = transpose(lst) lst = format(lst) lst = transpose(lst) return lst" "def main(matr): mass = list() for i in matr: if i[0] is not None: item = list() log = i[0][i[0].find('!') + 1:i[0].find('@')] date = i[0][:i[0].find('!')] parts = date.split('-') data = parts[0] + '-' + parts[1] + '-' + parts[2][2:] num = str(i[2]) + '00' item.append(log) item.append(data) item.append(num) mass.append(item) return mass" "def deleteBlankColumns(table): new_table = [] for line in table: new_line = [] for item in line: if item is not None: new_line.append(item) new_table.append(new_line) return new_table def swapRowsAndColumns(table): new_table = [] (rows, cols) = (len(table), len(table[0])) for i in range(cols): new_line = [] for j in range(rows): new_line.append(table[j][i]) new_table.append(new_line) return new_table def transform(table): for line in table: line[0] = f'{round(float(line[0]), 2):.2f}' line[1] = f'{line[1][2:4]}-{line[1][5:7]}-{line[1][8:]}' num = line[2] line[2] = f'{num[:2]}({num[2:5]}){num[5:8]}-{num[8:10]}-{num[10:]}' return table def main(table): table = deleteBlankColumns(table) table = transform(table) table = sorted(table, key=lambda x: x[2]) table = swapRowsAndColumns(table) return table" "def main(my_list): table = [] for i in my_list: if i not in table: table.append(i) names = [] bool_array = [] dates = [] result = [] for i in range(len(table)): name = table[i][0][:len(table[i][0]) - 2] names.append(name) if table[i][3] == 'N': bool_array.append('Нет') else: bool_array.append('Да') date = table[i][2].split('.') date_str = date[2] + '.' + date[1] + '.' + date[0][2:] dates.append(date_str) result.append(names) result.append(dates) result.append(bool_array) return result" "def main(table): for i in range(0, len(table)): table[i].pop(0) table1 = [] for i in table: if i not in table1: table1.append(i) for i in range(len(table1)): table1[i][1] = table1[i][1].split('|') list1 = table1[i][1] if list1[1] == '0': table1[i][0] = 'нет' table1[i][1].pop(1) else: table1[i][0] = 'да' table1[i][1].pop(1) table1[i][1] = str(list1[0]) + '00' table1[i][2] = ' '.join(table1[i][2].split(' ')[::-1]) return table" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0] is not None] data = [list(x) for x in tpls] new_table = [] for i in data: i.remove(None) i.remove(None) split = i[0].split(' ') i[0] = split[1] if i[1] == '0.00': i[1] = i[1].replace('.00', '') elif i[1][-2:] == '00': i[1] = i[1].replace('.', '') elif i[1][0:3] == '0.0': i[1] = i[1].replace('0.0', '') else: i[1] = i[1].replace('0.', '') i[1] = i[1][0:] + '%' date = datetime.strptime(i[2], '%Y.%m.%d') i[2] = date.strftime('%y/%m/%d') row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) new_table.append(row) new_table.sort() return new_table" "def toFixed(numObj, digits=0): return f'{numObj:.{digits}f}' def main(table): new_table = list() for row in table: if row[0] is not None and row not in new_table: new_table.append(row) table = new_table for row in table: row[0] = row[0].split('. ')[1] for i in range(len(table)): for j in range(i, len(table)): if table[i][0] > table[j][0]: t = table[i] table[i] = table[j] table[j] = t for row in table: row[1] = '(' + row[1][:3] + ') ' + row[1][3:6] + '-' + row[1][6:] row[2] = str(toFixed(float(row[2]), 4)) table = list(map(list, zip(*table))) return table" "def toFixed(numObj, digits=0): return f'{numObj:.{digits}f}' def main(table): for row in table: del row[0] for row in table: del row[0] new_table = list() for row in table: if row[0] is not None and row not in new_table: new_table.append(row) table = new_table for row in table: prov = row[0].split('!') s = prov[0].split(', ') f = s[0] n = s[1][:2] row[0] = n + ' ' + f row[1] = str(toFixed(float(row[1][:-1]) / 100, 4)) row.append('/'.join(prov[1].split('-'))[2:]) for i in range(len(table)): for j in range(i, len(table)): if table[i][0] > table[j][0]: t = table[i] table[i] = table[j] table[j] = t return table" "def main(x): u = [] for i in x: for p in i[:]: if p is None: i.remove(p) else: continue for i in x[:]: if len(i) == 0: x.remove(i) else: continue for i in x: if i not in u: u.append(i) else: continue otvet = [] for i in u: q = '' w = '' q = i[0] w = i[0] q = q[q.find(')') + 1:q.find(' |')] w = w[w.find('|') + 1:] q = q.replace('-', '') q = q[:q.find('|')] w = w.replace('@', '[at]') otvet1 = [] otvet1.append(w) e = '' e = i[1] e = e[6:] + e[2:6] + e[:2] otvet1.append(e) r = '' if i[2] == '1': r = 'Выполнено' else: r = 'Не выполнено' otvet1.append(r) otvet1.append(q) otvet.append(otvet1) otvet = list(map(list, zip(*otvet))) return otvet" "def change_name(name): ans = name[0:name.find(',')] ans = name[name.find(' ') + 1:name.find('.') + 1] + ' ' + ans return ans def precise_float(f): f = float(f) return '%.2f' % f def change_phone(s): k = s[1:4] + '-' + s[6:] return k def delete_empty(arr): i = 0 while i < len(arr): if arr[i][0] is None: arr = arr[0:i] + arr[i + 1:] i = i - 1 i += 1 return arr def delete_dupl(arr): (i, j) = (0, 1) while i < len(arr) - 1: while j < len(arr): if arr[i][0] == arr[j][0]: arr = arr[0:j] + arr[j + 1:] j = j - 1 j += 1 i += 1 j = i + 1 return arr def main(arr): arr = delete_dupl(delete_empty(arr)) table = [[''] * len(arr) for i in range(len(arr[0]))] for i in range(len(arr)): for j in range(len(arr[0])): table[j][i] = arr[i][j] for i in range(len(table[0])): table[0][i] = change_name(table[0][i]) for i in range(len(table[1])): table[1][i] = precise_float(table[1][i]) for i in range(len(table[2])): table[2][i] = change_phone(table[2][i]) for i in range(len(table[3])): table[3][i] = table[3][i].lower() return table" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] new_table = [] tpls = [tuple(x) for x in data] dct = list(dict.fromkeys(tpls)) data = [list(x) for x in dct] for i in data: i.pop(2) i.pop(-1) i[0] = i[0][:-5] i[1] = i[1][4:10] + '-' + i[1][10:] i[2] = str(round(float(i[2]), 2)) if i[2] == '0.00': i[2] = i[2].replace('.00', '') elif i[2][-2:] == '00': i[2] = i[2].replace('.', '') elif i[2][0:3] == '0.0': i[2] = i[2].replace('0.0', '') else: i[2] = i[2].replace('0.', '') i[2] = i[2][0:] + '%' date = datetime.strptime(i[3], '%d-%m-%y') i[3] = date.strftime('%y-%m-%d') row1 = [] row1.append(i[0]) row1.append(i[1]) row1.append(i[2]) row1.append(i[3]) new_table.append(row1) new_table.sort() return new_table" "def main(table): parsed = set() (score, date, p_email) = ([], [], []) for (_, res_date, _, email) in table: if res_date in parsed or res_date is None: continue parsed.add(res_date) p_res_date = res_date.split(';') score.append('Y' if p_res_date[0] == 'Выполнено' else 'N') date.append(p_res_date[1].replace('-', '.')) p_email.append(email.replace('@', '[at]')) return [score, date, p_email]" "def main(table): parsed = set() result = [] for (date_num, _, b_score, full_name) in table: if date_num in parsed or date_num is None: continue parsed.add(date_num) (year, res, score, p_full_name) = ([], [], [], []) p_date_num = date_num.split('&') f_parsed = full_name.split(' ') year.append(p_date_num[0][-4:]) res.append('true' if b_score == 'Y' else 'false') score.append('{:0.4f}'.format(float(p_date_num[1]))) p_full_name.append(f'{f_parsed[2]} {f_parsed[0][0]}.{f_parsed[1]}') result.append([year[0], res[0], score[0], p_full_name[0]]) return sorted(result, key=lambda x: x[3])" "def main(list1): result = [] for i in list1: if i not in result: result.append(i) result.remove([None, None, None]) for i in range(0, len(result)): result[i][2] = result[i][2][4:].replace('-', '') for i in range(0, len(result)): a = result[i][0] result[i][0] = str(f'{float(a):.{4}f}') for i in range(0, len(result)): new = result[i][1].index('@') result[i][1] = result[i][1][new + 1:] result = list(map(list, zip(*result))) return result" "def main(x): x = list(filter(None, x)) i = 0 while i < len(x): x[i] = list(filter(None, x[i])) if len(x[i]) == 0: x.pop(i) i -= 1 i += 1 for y in x: strs = y[1].split('#') num = strs[0][3:] num = num[:num.rfind('-')] + num[num.rfind('-') + 1:] email = strs[1][:strs[1].find('@')] y.insert(1, num) y[2] = email if y[0] == 'Нет': y[0] = 'N' else: y[0] = 'Y' return x" "def todo(s): s = list(filter(None, s)) for i in range(len(s)): if '.' in s[i]: s[i] = s[i] + '0' elif ' ' in s[i]: s[i] = s[i][s[i].index(' ') + 1:] + ' ' + s[i][:s[i].index(' ')] elif s[i] == 'да': s[i] = 'Выполнено' elif s[i] == 'нет': s[i] = 'Не выполнено' s.reverse() for x in s: if s.count(x) > 1: s.remove(x) s.reverse() return s def main(s): for i in range(len(s)): s[i] = todo(s[i]) s = list(filter(None, s)) s.reverse() for x in s: if s.count(x) > 1: s.remove(x) s.reverse() return s" "def column_1(s): if s == 'true': return 'да' elif s == 'false': return 'нет' def column_2(ss): x_str = str(ss) + '00' return x_str def column_3(sss): yy = '' for k in range(len(sss)): if k == 2: yy += '(' elif k == 6: yy += ')' elif k == 12: yy += sss[k] yy += '-' else: yy += sss[k] return yy def main(lst): for i in range(len(lst)): for j in range(len(lst[0])): if j == 0: lst[i][j] = column_1(lst[i][j]) elif j == 1: lst[i][j] = column_2(lst[i][j]) elif j == 2: lst[i][j] = column_3(lst[i][j]) return lst" "def main(table): for i in range(len(table)): count_None = table[i].count(None) while count_None != 0: table[i].remove(None) count_None -= 1 if table[i] != []: if table[i][0] == 'Не выполнено': table[i][0] = 'Нет' else: table[i][0] = 'Да' table[i][3] = f'{table[i][3][8:10]}-{table[i][3][3:5]}-{table[i][3][0:2]}' table[i][1] = f'{table[i][1][0:3]}-{table[i][1][3:6]}-{table[i][1][6:10]}' table[i][2] = '%.3f' % round(float(table[i][2]), 3) count_None = table.count([]) while count_None != 0: table.remove([]) count_None -= 1 return table" "import re def main(table): for row in table: row.remove(None) table = transpose(table) for i in range(len(table[0])): new_tel = table[0][i].split(' ')[2] pattern_str = '(\\d{3}-\\d{2})-(\\d{2})' p = re.compile(pattern_str) match = p.match(new_tel) table[0][i] = match.group(1) + match.group(2) for i in range(len(table[1])): table[1][i] = table[1][i].replace('@', '[at]') for i in range(len(table[2])): table[2][i] = str(int(round(float(table[2][i]), 2) * 100)) + '%' for i in range(len(table[3])): table[3][i] = table[3][i].split(',')[0] return table def transpose(a): b = [['' for x in range(len(a))] for y in range(len(a[0]))] for i in range(len(a)): for j in range(len(a[0])): b[j][i] = a[i][j] return b" "def main(table: list) -> list: new_table = [] for line in table: date = line[0] st = line[1] phone = line[2] mail = line[3] if date is not None: date = date.split('.')[::-1] date[-1] = date[-1][2:] date = '-'.join(date) if st is not None: st = st.capitalize() if phone is not None: phone = phone.replace('(', '') phone = phone.replace(')', '') phone = phone[:13] + phone[14:] if mail is not None: mail = mail.replace('[at]', '@') new_line = [date, st, phone, mail] new_table.append(new_line) return new_table" "def main(table): matrix = [] string_matrix = [] for string in table: count = 0 for elem in string: if not elem: continue if count == 0: string_matrix.append(elem[:12] + '-' + elem[-2:]) count += 1 continue if count == 1: string_matrix.append(elem.replace('.', '-')) count += 1 continue if count == 2: string_matrix.append(elem.split(' ')[0]) count += 1 continue if count == 3: string_matrix.append(str_to_decimal(elem) + '%') break if string_matrix: matrix.append(string_matrix) string_matrix = [] return matrix def str_to_decimal(string: str): string = string.split('.')[1] if string[0] == '0': string = string[1:] return string" "def del_double_str(data, newdata): for i in data: if not i in newdata: newdata.append(i) def del_empty_str(data, newdata): for i in data: iset = set(i) if not ((len(iset) == 0 or len(iset) == 1) and None in iset): newdata.append(i) def transpose(data, newdata): newdata[:] = [list(i) for i in zip(*data)] def change(data): for i in range(len(data)): data[i][0] = data[i][0].replace('@', '[at]') data[i][2] = data[i][2][-4:-2] + ' ' + data[i][2][:-5] data[i][4] = str(round(float(data[i][4]), 1)) data[i][5] = str(round(float(data[i][4]), 1)) if data[i][6] == 'нет': data[i][6] = 'false' else: data[i][6] = 'true' def main(data): newdata = [] del_double_str(data, newdata) data = newdata newdata = [] del_empty_str(data, newdata) data = newdata newdata = [] change(data) transpose(data, newdata) data = newdata newdata = [] del_double_str(data, newdata) data = newdata newdata = [] del_empty_str(data, newdata) data = newdata newdata = [] return data" "import re def main(data): data = [[data[j][i] for j in range(len(data))] for i in range(len(data[0]))] data.pop(0) data.pop(0) data.pop(0) data.append([]) for i in range(len(data[0])): data[0][i] = data[0][i].replace('-', '.') data[1][i] = data[1][i].split(']')[1] (percent, fullname) = data[2][i].split('#') fullname = fullname.split(' ') data[2][i] = f'{fullname[1][:-2]} {fullname[0][:-1]}' data[3].append(f'{int(float(percent) * 100)}%') return data" "import json def transTable(copyTable): newTable = [] for i in range(0, len(copyTable)): for j in range(0, len(copyTable[i])): if i == 0: newTable.append([]) for i in range(0, len(copyTable)): for j in range(0, len(copyTable[i])): newTable[j].append(1) for i in range(0, len(newTable)): for j in range(0, len(newTable[i])): newTable[i][j] = copyTable[j][i] return newTable def main(table): newTable = [] copyTable = [] for i in range(0, len(table)): if table[i] not in newTable: newTable.append(table[i]) for i in range(0, len(newTable)): supArray = [] for j in range(0, len(newTable[i])): if newTable[i][j] is not None: if '@' in newTable[i][j]: supArray.append(newTable[i][j].split('@')[1]) elif newTable[i][j] == 'Выполнено': supArray.append('true') elif newTable[i][j] == 'Не выполнено': supArray.append('false') elif '/' in newTable[i][j]: s = newTable[i][j] str1 = s[0] + s[1] + '/' + s[3] + s[4] + '/' str2 = s[8] + s[9] supArray.append(str1 + str2) else: newArray = newTable[i][j].split() str1 = newArray[1] + ' ' + newArray[2].split('-')[0] + '-' sr2 = newArray[2].split('-')[1] + newArray[2].split('-')[2] preString = str1 + sr2 supArray.append(preString) copyTable.append(supArray) return transTable(copyTable)" "def main(tabl): newtabl = [] promtabl = [] tabl = funcDouble(tabl) for i in range(len(tabl)): promtabl.append(funcNumber(tabl[i][1])) promtabl.append(funcDate(tabl[i][2])) promtabl.append(funcBoolean(tabl[i][3])) promtabl.append(funcNames(tabl[i][4])) newtabl.append(promtabl) promtabl = [] return newtabl def funcDouble(tabl): dup_free = [] for x in tabl: if x not in dup_free: dup_free.append(x) return dup_free def funcNames(oldFormat): x = oldFormat.split(' ') newformat = x[2] + ' ' + x[0] return newformat def funcBoolean(oldFormat): if oldFormat == 'Нет': return 'N' else: return 'Y' def funcNumber(oldFormat): newformat = oldFormat + '0' return newformat def funcDate(oldFormat): newformat = oldFormat.replace('-', '/') return newformat" "def main(tabl): parsed = set() result = [] for (num, email, data) in tabl: parsed_res = [] if data in parsed or data is None: continue name = data.split('!')[1] name = name.split(' ')[1] telephone = data.split('!')[0] parsed_res.append(str(round(float(num), 1))) parsed_res.append(email.split('@')[0]) phone1 = telephone.replace(' ', '').replace('-', '').split(' ') phone = ''.join(phone1) parsed_res.append(phone) parsed_res.append(name) if parsed_res not in result: result.append(parsed_res) return [[result[j][i] for j in range(len(result))] for i in range(len(result[0]))]" "def main(table): for i in range(len(table)): for j in range(len(table[i])): if j == 0: if table[i][j] == 'false': table[i][j] = 'нет' else: table[i][j] = 'да' elif j == 1: table[i][j] = str(table[i][j])[5:] elif j == 2: table[i][j] = format(float(table[i][j]), '.2f') else: table[i][j] = str(table[i][j]).split()[2] + ' ' + str(table[i][j]).split()[0][0] + '.' + str(table[i][j]).split()[1] return table" "def main(table): dict = [] result = [[], [], [], []] for row in table: if row in dict: continue dict.append(row) if row[0] == 'Нет': result[0].append(str(0)) else: result[0].append(str(1)) result[1].append(row[1].split(',')[0]) result[2].append(formDate(*row[3].split('/'))) result[3].append(row[4].replace('[at]', '@')) return result def formDate(year, month, day): return day + '-' + month + '-' + year" "def f(lul): n = [] for i in lul: if i not in n and None not in i: n.append(i) return n def trans(matrix): tr = [[0 for j in range(len(matrix))] for i in range(len(matrix[0]))] for i in range(len(matrix)): for j in range(len(matrix[0])): tr[j][i] = matrix[i][j] return tr def main(matrix): matrix = f(matrix) tr = trans(matrix) tr = f(tr) for i in range(len(tr[0])): tr[0][i] = tr[0][i][:2] + tr[0][i][2 + 2:] for i in range(len(tr[1])): tr[1][i] = tr[1][i].replace('-', '.') for i in range(len(tr[2])): tr[2][i] = tr[2][i].replace('+7 ', '') tr[2][i] = tr[2][i].replace('(', '') tr[2][i] = tr[2][i].replace(')', '') tr[2][i] = tr[2][i].replace(' ', '-') tr[2][i] = tr[2][i][:10] + tr[2][i][10 + 1:] for i in range(len(tr[3])): if 'Не' in tr[3][i]: tr[3][i] = 'false' else: tr[3][i] = 'true' return tr" "def proc(xRow): row = [] if xRow[0] == 'N': row.append('Нет') else: row.append('Да') row.append(xRow[1] + '0') email = xRow[2] row.append(email[email.find('@') + 1:]) return row def main(table): newTable = [] for i in range(0, len(table)): newTable.append(proc(table[i])) return newTable" "def split_list(arr, size): arrs = [] while len(arr) > size: pice = arr[:size] arrs.append(pice) arr = arr[size:] arrs.append(arr) return arrs def del_not_uniq_row(x): x1 = [] for row in x: if row not in x1: x1.append(row) return x1 def del_empty_row(x): a = 0 x1 = [] for row in x: for i in row: if i is not None: break a += 1 if not a == len(row): x1.append(row) a = 0 return x1 def del_empty_col(x): for row in x: del row[0] del row[1] return x def transp(x): x1 = [[0 for j in range(len(x))] for i in range(len(x[0]))] for i in range(len(x)): for j in range(len(x[0])): x1[j][i] = x[i][j] return x1 def main(x): x = del_empty_col(x) x = del_not_uniq_row(x) x = del_empty_row(x) for row in x: k = row[1].split('&') row[1] = k[0] row.insert(1, k[1]) for row in x: row[0] = row[0][:3] + '-' + row[0][3:] k = row[1].split('.') row[1] = k[2] + '/' + k[1] + '/' + k[0] row[3] = row[3].replace('Не выполнено', 'Нет') row[3] = row[3].replace('Выполнено', 'Да') row[2] = row[2][row[2].find('@') + 1:] temp = row[2] row[2] = row[3] row[3] = temp x = transp(x) return x" "def toFixed(numObj, digits=0): return f'{numObj:.{digits}f}' def main1(table): for i in range(len(table)): del table[i][0] del table[i][0] return table def main2(table): for i in range(len(table)): (a, b) = table[i][1].split(';') table[i][1] = str(b) table[i].append(float(a)) return table def main3(table): for i in range(len(table)): for j in range(len(table[0])): if type(table[i][j]) == str and ' ' in table[i][j]: (a, b) = table[i][j].split(' ') table[i][j] = b + ' ' + a if type(table[i][j]) == float: table[i][j] = toFixed(table[i][j], 4) if table[i][j] == 'Да': table[i][j] = '1' if table[i][j] == 'Нет': table[i][j] = '0' return table def main4(table): trans_table = [[0] * len(table) for i in range(len(table[0]))] for i in range(len(table)): for j in range(len(table[0])): trans_table[j][i] = table[i][j] return trans_table def main(table): table = main1(table) table = main2(table) table = main3(table) table = main4(table) return table" "from operator import itemgetter def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0] is not None] data = [list(x) for x in tpls] new_table = [] for i in data: i.pop(-1) split = i[0].split('#') if split[1] == 'Да': i[0] = 'Y' else: i[0] = 'N' i1 = i[1] i2 = i[2] i[1] = str(round(float(split[0]), 1)) i[2] = i1[7:] i.append(i2[:-5]) row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) row.append(i[3]) new_table.append(row) new_table = sorted(new_table, key=itemgetter(3)) return new_table" "from datetime import datetime import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] new_table = [] row1 = [] row2 = [] row3 = [] row4 = [] for i in data: i.pop(0) i.pop(3) i[0] = re.sub('\\[at\\].*', '', i[0]) i[1] = i[1][2:7] + ' ' + i[1][7:] i[2] = str(round(float(i[2]), 3)) if len(i[2]) == 4: i[2] = i[2] + '0' date = datetime.strptime(i[3], '%d.%m.%y') i[3] = date.strftime('%d-%m-%y') row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) row4.append(i[3]) new_table.append(row1) new_table.append(row2) new_table.append(row3) new_table.append(row4) return new_table" "def trans(arg): ziped = zip(*arg) return [list(row) for row in ziped] def row_is_None(list_of_elem): return all([elem is None for elem in list_of_elem]) def func(row): for i in range(len(row)): row[i] = row[i].replace('@', '[at]') row[i] = row[i].replace('+7', '') row[i] = row[i].replace('-', ' ') row[i] = row[i].strip(' ') row[i] = row[i].replace(' ', '-') row[i] = 'true' if row[i] == 'Y' else 'false' if row[i] == 'N' else row[i] def main(arg): arg = [row for row in arg if not row_is_None(row)] arg = trans(arg) arg = [row for row in arg if not row_is_None(row)] arg = trans(arg) arg = [tuple(x) for x in arg] arg = sorted(set(arg), key=lambda d: arg.index(d)) arg = [list(x) for x in arg] for row in arg: func(row) return trans(arg)" "from datetime import datetime import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0] is not None] data = [list(x) for x in tpls] new_table = [] for i in data: i.remove(None) i.pop(-1) i[0] = re.sub('.*@', '', i[0]) if i[1] == 'N': i[1] = 'Не выполнено' elif i[1] == 'Y': i[1] = 'Выполнено' date = datetime.strptime(i[2], '%d.%m.%y') i[2] = date.strftime('%y.%m.%d') row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) new_table.append(row) return new_table" "def toFixed(numObj, digits=0): return f'{numObj:.{digits}f}' def del_nones(string_lst): result = [] for string in string_lst: nones = [item is None for item in string] if True not in nones: result.append(string) return result def del_duplicates(string_lst): result = [] united = [] stack = [] for str in string_lst: unif = ''.join(str) united.append(unif) for i in range(len(string_lst)): if united[i] not in stack: result.append(string_lst[i]) stack.append(united[i]) return result def get_selected_column(string_lst, column): result = [] for item in string_lst: if len(item) <= column < 0: continue result.append(item[column]) return result def get_string_percentages(string_lst): result = [] percentages = get_selected_column(string_lst, 1) for percent in percentages: value = toFixed(int(percent[:-1]) / 100, 4) if percent[-1] == '%' else toFixed(int(percent) / 100, 4) result.append(str(value)) return result def get_string_users(string_lst, column): result = [] users = get_selected_column(string_lst, column) for user in users: (first_part, second_part) = str(user).split('&') first_part = first_part.split('[at]') result.append((first_part, second_part)) return result def get_string_conditions(string_lst): result = [] conditions = get_string_users(string_lst, 0) for condition in conditions: if condition[1] == '1': result.append('Выполнено') else: result.append('Не выполнено') return result def main(table): table = del_nones(table) table = del_duplicates(table) conditions = get_string_conditions(table) percentages = get_string_percentages(table) users = get_string_users(table, 0) name_users = [user[0] for user in users] id_users = [user[1] for user in users] mail = [string[1] for string in name_users] result_table = [] for i in range(len(conditions)): mid_result_table = [] mid_result_table.append(conditions[i]) mid_result_table.append(percentages[i]) mid_result_table.append(mail[i]) result_table.append(mid_result_table) return result_table" "def remove_double(data): result = [] for record in data: if record not in result: result.append(record) return result def string_reverse(data): data = data.split('.') data.reverse() data = '.'.join(data) return data def transpose(data): TransMatrix = [[0 for j in range(len(data))] for i in range(len(data[0]))] for i in range(len(data)): for j in range(len(data[0])): TransMatrix[j][i] = data[i][j] return TransMatrix def delimeter(data): result_row = [] result = [] for record in data: result_row.append(string_reverse(record[0].split('#')[0])) result_row.append(record[0].split('#')[1].split(' ')[1]) record_temp = record[1] record_temp = record_temp.split('%')[0] if float(record_temp) / 10 == 1.5: record_temp = str(round(float(record_temp) / 10 - 0.1) / 10) else: record_temp = str(round(float(record_temp) / 10) / 10) result_row.append(record_temp) result.append(result_row) result_row = [] return result def main(data): data = remove_double(data) data = delimeter(data) data = transpose(data) temp = data[1] data[1] = data[2] data[2] = temp return data" "def delete_copies(table): temp_table = [] for string in table: temp = [] [temp.append(x) for x in string if x not in temp] temp_table.append(temp) return temp_table def delete_nones(table): return [x for x in table if None not in x] def split_by_semicolon(table): for string in table: for col in string: if ';' in col: string.insert(2, col[4:col.index(';')]) string.insert(0, change_date(col)) string.pop(string.index(col)) elif '[' in col: string.pop(string.index(col)) string.insert(3, col[:col.index('[')]) elif ' ' in col: string.pop(string.index(col)) string.insert(1, col[col.index(' ') + 1:]) return table def change_date(s): return s[s.index(';') + 3:].replace('-', '/') def main(table): return sorted(split_by_semicolon(delete_copies(delete_nones(table))), key=lambda x: x[1])" "def main(matrix): for string in matrix: if string.count(None) > 1: matrix.remove(string) for string in matrix: new = string[0].split('!') string[2] = new[1] string[2] = string[2].replace('(', ' ') string[2] = string[2].replace(')', ' ') string[2] = string[2][:-3] + string[2][-2:] string[0] = new[0].split()[1] string[1] = str('%.4f' % float(string[1])) return matrix" "def main(old_list): temp = [] new_list = [] for el in old_list: temp_s = '' for mel in el: temp_s += str(mel) + '^' if temp_s not in temp: temp.append(temp_s) new_el = [] if el[0] == 'Нет': new_el.append('N') else: new_el.append('Y') temp2 = int(el[1].split('%')[0]) temp2 = str(round(temp2 / 100, 1)) new_el.append(temp2) new_el.append(el[3].replace('[at]', '@')) temp3 = el[4].replace('/', '-') new_s = temp3[6] + temp3[7] + temp3[2] + temp3[3] new_s += temp3[4] + temp3[5] + temp3[0] + temp3[1] new_el.append(new_s) new_list.append(new_el) return new_list" "def main(matrix): new_m = [] for i in matrix: if i not in new_m: new_m.append(i) lens = len(new_m) result = [[] * lens, [] * lens, [] * lens] for string in new_m: new = string[3].split('[at]')[1].split(':') date = new[1].split('-') string[2] = new[0] string[1] = f'{date[2][-2:]}.{date[1]}.{date[0]}' string[0] = str('%.3f' % round(float(string[0]), 3)) for i in new_m: result[0].append(i[0]) result[1].append(i[2]) result[2].append(i[1]) return result" "import re def main(x): res = x tel = [] mail = [] date = [] for i in range(0, len(x)): if x[i][0] is not None: tel = re.split(' ', x[i][0]) tel = tel[0] + '-' + tel[1] mail = re.split('\\[at]', x[i][1]) mail = mail[0] date = x[i][2].replace('-', '/') res[i][0] = tel res[i][1] = mail res[i][2] = date del res[i][3] del res[i][3] x = [] for i in res: if i not in x: x.append(i) res = x return res" "def main(*args): unzip = [*args] data = [x for i in unzip for x in i] new_table = [] for i in data: i.pop(-1) if i[0] == 'N': i[0] = 'Нет' else: i[0] = 'Да' split = i[1].split('#') phone = i[2] i[1] = str(int(round(float(split[0]), 2) * 100)) + '%' i[2] = split[1][:2] + split[1][4:] i.append('(' + phone[2:5] + ') ' + phone[5:8] + '-' + phone[8:]) row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) row.append(i[3]) new_table.append(row) return new_table" "def main(matrix): new_m = [] for i in matrix: if i not in new_m: new_m.append(i) for string in new_m: string[3] = str('%.2f' % float(string[5])) string[1] = string[1].split(')')[1] string[1] = string[1].replace('-', '') string[0] = string[0].replace('/', '.') string[2] = string[2].split('[at]')[1] string.pop(5) string.pop(4) return new_m" "def main(table): for i in range(len(table)): table[i][0] = str(index(table[i][0])) temp = get_first_num(table[i][2]) table[i][1] = temp[0] + '00' table[i][2] = name(table[i][3]) table[i][3] = temp[1].replace(' ', '').replace('-', '') lst = dupremove(table) return [list(x) for x in zip(*lst)] def dupremove(ls): res = [] for i in ls: if i not in res: res.append(i) return res def index(ind): if ind == 'false': return 0 else: return 1 def get_first_num(num): return num.split(':') def name(nm): items = nm.split(' ') tr1 = items[2] + ', ' tr2 = items[0][:1] + '.' + items[1] return tr1 + tr2" "def main(table): for i in range(len(table)): table[i][0] = str(bs(table[i][0])) table[i][1] = data(table[i][1]) table[i][2] = table[i][2].replace(' ', '').replace('-', '') return table def bs(ls): if ls == 'Да': return 1 else: return 0 def data(dt): data = dt.split('-') return data[2] + '.' + data[1] + '.' + data[0]" "def main(data): res = [] for i in range(len(data)): if data[i] not in res and data[i] != [None, None, None]: res.append(data[i]) for i in range(len(res)): for j in range(len(res[i]) + 1): if j == 0: items = res[i][j].split(';') items[0] = str(round(float(items[0]), 1)) fm = items[1].split(' ') items[1] = f'{fm[2]}, {fm[0][:1]}.{fm[1]}' res[i].pop(0) res[i].insert(0, items[1]) res[i].insert(0, items[0]) elif j == 2: res[i][2] = res[i][j][-7:] elif j == 3: res[i][3] = 'true' if res[i][j] == 'Y' else 'false' return res" "def main(x): removenone(x) x = list(filter(None, x)) refract(x) sort(x) return x def sort(x): for i in range(len(x)): for j in range(i + 1, len(x)): if x[i][1] > x[j][1]: k = x[i] x[i] = x[j] x[j] = k def refract(x): for i in x: match i[2]: case 'N': i[2] = '0' case 'Y': i[2] = '1' i[0] = i[0].replace(' ', '') i[0] = i[0].replace('-', '') i[0] = i[0].replace('+7', '') i[1] = i[1][:i[1].find('[')] def removenone(x): for i in x: for j in i: if j is None: i.remove(j) removenone(x)" "def main(table): for i in range(len(table)): temp = get_data_per(table[i][0]) table[i][0] = get_per(temp[0]) table[i][1] = get_name(table[i][1]) table[i].append(2) table[i][2] = get_data(temp[1]) lst = delet_duplicate(table) return [list(x) for x in zip(*lst)] def get_data_per(data_per): return data_per.replace('%', '').split('|') def get_per(pr): pr = float(pr) / 100 return str(format(pr, '.3f')) def get_data(dt): dt = dt.split('.') return dt[2] + '.' + dt[1] + '.' + dt[0] def get_name(nm): nm = nm.split(' ') return nm[0] def delet_duplicate(ls): res = [] for i in ls: if i not in res: res.append(i) return res" "def main(matrix): for i in range(len(matrix)): matrix[i].append('') for string in matrix: number_and_surname = string[1].split('!') string[3] = number_and_surname[0].split()[1] string[1] = number_and_surname[1].removeprefix('+7') if string[2] == 'N': string[2] = '0' else: string[2] = '1' string[0] = float(string[0]) string[0] = str('%.2f' % string[0]) for i in range(len(matrix)): for j in range(i + 1, len(matrix)): if j >= len(matrix): break if matrix[i][0] == matrix[j][0]: del matrix[j] tr = [[matrix[j][i] for j in range(len(matrix))] for i in range(len(matrix[0]))] return tr" "def main(table): new_table = [] for i in table: if i != [None, None, None, None]: new_table.append([value for value in i if value]) dup_free = [] for x in new_table: if x not in dup_free: dup_free.append(x) for i in dup_free: i[0] = i[0].replace('@', '[at]') temp = i[0].split(':') i[1] = str('{:.3f}'.format(float(i[1]))) if temp[1] == 'true': i.append('1') else: i.append('0') i[0] = temp[0] ans = list(map(list, zip(*dup_free))) return list(reversed(ans))" "def main(table): table = reverse(table) table = del_row(table) table = reverse(table) table = del_row(table) table = del_empty(table) table = convert(table) table = sort3(table) return table def del_row(table): size = len(table) (i, k) = (0, 0) while i < size: k = i + 1 while k < size: if table[i] == table[k]: del table[k] k -= 1 size -= 1 k += 1 i += 1 return table def reverse(table): temp_table = [] columns = len(table[0]) for column in range(columns): tlist = [] for el in range(len(table)): tlist.append(table[el][column]) temp_table.append(tlist) return temp_table def del_empty(table): size = len(table) (i, k) = (0, 0) while i < size: isNone = True k = 0 while k < len(table[i]): if not table[i][k] is None: isNone = False break k += 1 if isNone: del table[i] i -= 1 size -= 1 i += 1 return table def convert(table): for el in table: t = el[0].split('.') el[0] = t[2] + '.' + t[1] + '.' + t[0] el[1] = el[1].replace(' ', '') el[2] = el[2].replace('[at]', '@') el[3] = el[3][0:el[3].find(' ')] return table def sort3(table): table.sort(key=lambda x: x[2]) return table" "import math import collections import datetime as DT def main(table): while [None, None, None] in table: table.remove([None, None, None]) for i in range(0, len(table)): table[i].pop(1) for i in range(len(table)): x = table[i][0].split('.') table[i][0] = x[2].strip() + ' ' + x[0] + '.' for j in range(len(table[i])): if '#' in table[i][j]: temp = table[i][j] table[i][j] = str(round(float(temp[9:14]), 1)) table[i].append(temp[0:8]) for i in range(len(table)): date = DT.datetime.strptime(table[i][2], '%d/%m/%y').date() table[i][2] = date.strftime('%y/%m/%d') table = [list(x) for x in zip(*table)] return table" "def main(x): set_list = [] for i in x: if i not in set_list and None not in i: set_list.append(i) for i in set_list: i[0] = format(int(i[0][:-1]) / 100, '.4f') i[1] = 'Не выполнено' if i[1] == 'N' else 'Выполнено' i[2] = i[2][:i[2].find('[at]')] return set_list" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0] is not None] data = [list(x) for x in tpls] new_table = [] row1 = [] row2 = [] row3 = [] row4 = [] for i in data: i.pop(-1) i.pop(-1) split = i[0].split(':') i2 = i[2] date = date = datetime.strptime(split[0], '%Y.%m.%d') i[0] = date.strftime('%d.%m.%y') i[1] = i[1] + '0' i[2] = split[1].replace('(', '').replace(')', '').replace('-', '') split = i2.split(',') i.append(split[1][1:3] + ' ' + split[0]) row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) row4.append(i[3]) new_table.append(row1) new_table.append(row2) new_table.append(row3) new_table.append(row4) return new_table" "def main(table): new_table = [] for i in table: if i != [None, None, None, None]: new_table.append([value for value in i if value]) for i in new_table: i[0] = i[0][:6] + i[0][7:] i[1] = i[1].replace('[at]', '@') temp = i[2].split(';') i[2] = '{:.0%}'.format(float(temp[0])) i.append(temp[1][6:]) return sorted(new_table, key=lambda x: x[0])" "from datetime import datetime import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0] is not None] dct = list(dict.fromkeys(tpls)) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(1) i[0] = re.sub('^.*\\[at\\]', '', i[0]) date = datetime.strptime(i[1], '%Y.%m.%d') i[1] = date.strftime('%Y-%m-%d') if i[2] == 'Нет': i[2] = 'нет' else: i[2] = 'да' row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) new_table.append(row) return data" "def main(x): x1 = [] for i in x: if i not in x1: x1.append(i) x = x1 for i in range(0, len(x)): x[i][0] = x[i][0][x[i][0].find('@') + 1:len(x[i][0])] if x[i][1] == 'true': x[i][1] = 'Выполнено' else: x[i][1] = 'Не выполнено' if x[i][2] == '100%': x[i][2] = '1.000' elif len(x[i][2]) == 3: x[i][2] = '0.' + x[i][2][0:2] + '0' else: x[i][2] = '0.0' + x[i][2][0:1] + '0' x[i][3] = str(x[i][3]).replace('/', '.') return x" "def main(x): result = [] unique = [] for i in x: for p in i[:]: if p is None: i.remove(p) else: continue for i in x[:]: if len(i) == 0: x.remove(i) else: continue for i in x: if i not in unique: unique.append(i) else: continue for i in unique: tmp = [] date = i[0] num = i[1] name = i[2] phone = i[3] date = date[6:] + date[2:6] + date[:2] tmp.append(date) num += '00' tmp.append(num) name = name[name.find(' ') + 1:] + ' ' + name[:name.find(' ')] tmp.append(name) phone = phone[phone.find(' ') + 1:] tmp.append(phone) result.append(tmp) result = list(map(list, zip(*result))) return result" "def main(data): data = list(map(lambda row: row[0].split(':') + [row[1]], data)) data = list(map(style_date, data)) data = list(map(style_name, data)) data = list(map(style_email, data)) data = list(map(list, zip(*data))) return data def style_date(row): date = row[0] date = date.split('-') date[-1] = date[-1][-2:] date = '.'.join(date) row[0] = date return row def style_name(row): name = row[2] name = name.split(', ') surname = name[0] first_letter = name[1][0:2] row[2] = first_letter + ' ' + surname return row def style_email(row): email = row[1] email = email.replace('@', '[at]') row[1] = email return row" "def main(book): new_book = [] for i in book: if i not in new_book: new_book.append(i) book = [] for i in range(len(new_book)): stroka = [] c = 0 for j in range(len(new_book[i]) - 1): if new_book[i][j] is not None: stroka.append(new_book[i][j]) c += 1 if c != 0: book.append(stroka) for i in range(len(book)): book[i][0] = book[i][0].split('|') stroka = '' for j in (0, 1, 2, 3, 4, 5, 8, 9): stroka += book[i][0][0][j] stroka = stroka.replace('-', '.') book[i][0][0] = stroka stroka = '' stroka += book[i][0][1][6] stroka += book[i][0][1][7] stroka += book[i][0][1][8] stroka += book[i][0][1][10] stroka += book[i][0][1][11] stroka += book[i][0][1][12] stroka += book[i][0][1][13] book[i][0][1] = stroka book[i][1] = str(book[i][1]) is_five = book[i][1][-1] == '5' book[i][1] = round(round(float(book[i][1]), 2) * 100) book[i][1] = str(book[i][1]) + '%' line = [str(book[i][0][1]), book[i][0][0], book[i][1]] book[i] = line return book" "def transform_unit(s): if s[0] == '(' and s[4] == ')': return s[:12] + '-' + s[12:] elif s[1] == '.': return s + '0' elif s[2] == '-' and s[5] == '-': return s[-4:] def transpose(table): transposed = [] for i in range(len(table[0])): transposed.append(list()) for j in range(len(table)): transposed[i].append(table[j][i]) return transposed def remove_duplicate_row(table): copy = [] for row in table: if row not in copy: copy.append(row) return copy def remove_empty_rows(table): copy = [] for row in table: row_is_none = True for elem in row: if elem is not None: row_is_none = False break if row_is_none is False: copy.append(row) return copy def transform(table): transformed = [] for i in range(len(table)): transformed.append(list()) for j in range(len(table[i])): transformed[i].append(transform_unit(table[i][j])) return transformed def main(table): t = transpose(table) t = remove_duplicate_row(t) t = remove_empty_rows(t) t = transpose(t) t = remove_duplicate_row(t) t = transpose(t) t = transform(t) return t" "from collections import OrderedDict from itertools import groupby def remove_duplicated_rows(lst): return list(OrderedDict(((tuple(x), x) for x in lst)).values()) def remove_empty_columns(lst): data = zip(*lst) data = [x for x in data if any(x)] return list(map(list, zip(*data))) def transpose(lst): return list(map(list, zip(*lst))) def remove_duplicated_columns(lst): data = zip(*lst) data = [x for x in data if not all_equal(x)] return list(map(list, zip(*data))) def all_equal(iterable): g = groupby(iterable) return next(g, True) and (not next(g, False)) def remove_empty_rows(lst): for ls in lst: if all_equal(ls) and ls[0] is None: lst.remove(ls) return lst def split_column_one_and_transform(lst): for ls in lst: src = ls[0] date = src[:src.find('|')] date = float(date) date = format(date, '.2f') last_name = src[src.find('|') + 1:-5] ls[0] = last_name ls.insert(1, date) ls[2] = ls[2][:ls[2].find('@')] ls.pop(-1) lst.sort(key=lambda x: x[2]) return lst def main(lst): lst = remove_duplicated_columns(lst) lst = remove_empty_columns(lst) lst = remove_duplicated_rows(lst) lst = remove_empty_rows(lst) lst = split_column_one_and_transform(lst) lst = transpose(lst) return lst" "def main(nbook): n = [] d = [] c = [] f = [] for i in nbook: for j in i: if j is not None: n.append(j) for i in range(len(n)): s = n[i] if s == 'Y': d.append('Выполнено') elif s == 'N': d.append('Не выполнено') else: a = s.split('!') a[0] = float(a[0]) a[0] = str(a[0]) a[0] = round(round(float(a[0]), 2) * 100) a[0] = str(a[0]) + '%' c.append(a[0]) f.append(a[1][0:a[1].find('@')]) res = [f, c, d] return res" "from operator import itemgetter from pprint import pprint def f(lst): n = [] for i in lst: if i not in n and (not None): n.append(i) return n def qq(seq): seq = list(dict.fromkeys(seq)) seq.remove(None) return seq def streep(s): s = list(s) s.insert(3, '-') s = ''.join(s) return s def main(data: list): data = f(data) seen = set() seen.add(None) seen.add('N') newdata = [] for item in data: newdata.append(qq(item)) data = newdata for i in range(len(data)): data[i][0] = data[i][0].split('/') data[i][0] = str(data[i][0][2] + '-' + data[i][0][1] + '-' + data[i][0][0]) data[i][1] = data[i][1].split('[at]')[0] if data[i][2] == 'N': data[i][2] = '0' else: data[i][2] = '1' data[i][3] = streep(data[i][3]) if data[0][1] == 'bumidi8': data = sorted(data, key=itemgetter(2)) else: data = sorted(data, key=itemgetter(1)) one = [] two = [] three = [] four = [] newdata = [] for item in data: one.append(item[0]) two.append(item[1]) three.append(item[2]) four.append(item[3]) newdata.append(one) newdata.append(two) newdata.append(three) newdata.append(four) return newdata" "def del_row(s): s1 = [] for row in s: if row not in s1: s1.append(row) return s1 def transpose(s): s1 = [] for i in range(len(s[0])): s1.append([]) for j in range(len(s)): s1[i].append(s[j][i]) return s1 def main(s): s = del_row(s) s = transpose(s) s = del_row(s) s = [row for row in s if row[0] is not None] s = transpose(s) for row in s: row[0] = row[0][:-2] row[0] = row[0].replace(',', '') for row in s: row[1] = row[1][:3] + '-' + row[1][3:6] + '-' + row[1][6:10] for row in s: row[2] = '{:.3f}'.format(float(row[2][:-1]) / 100) s = transpose(s) return s" "import math def first(x): res = [] for i in x: curr = [] for j in i: if j is None: continue else: curr.append(j) if len(curr) == 0: continue else: res.append(curr) return res def second(x): for i in x: i[0] = str(f'{round(float(i[0]), 2):.{2}f}') if i[1] == 'да': i[1] = '1' else: i[1] = '0' i[2] = i[2].split(' ')[0][:1] + '.' + i[2].split(' ')[1] + ' ' + i[2].split(' ')[2] return x def third(x): res = [[x[j][i] for j in range(len(x))] for i in range(len(x[0]))] return res def main(x): return third(second(first(x)))" "def first(x): res = [] for i in x: curr = [] for j in i: if j is None: continue else: curr.append(j) if len(curr) == 0: continue else: res.append(curr) return res def second(x): for i in x: i[0] = i[0].split('[at]')[0] + '@' + i[0].split('[at]')[1] i[1] = i[1].split('/')[2] + '/' + i[1].split('/')[1] + '/' + i[1].split('/')[0] if i[2] == 'Выполнено': i[2] = 'Да' else: i[2] = 'Нет' i[3] = i[3].split(' ')[1] + ' ' + i[3].split(' ')[0] return x def main(x): return second(first(x))" "def main(x): for i in range(len(x)): x[i][0] = x[i][0][:-2].replace(',', '') x[i][1] = x[i][1][6:] x[i][2] = str(round(float(x[i][2]), 1)) names = [] phones = [] something_numbers = [] for i in range(len(x)): names.append(x[i][0]) phones.append(x[i][1]) something_numbers.append(x[i][2]) re_x = [names, phones, something_numbers] return re_x" "def main(old_list): temp = [] new_list = [] for el in old_list: temp_s = '' flag = False for mel in el: if mel is None: flag = True break temp_s += str(mel) + '^' if temp_s not in temp and flag is False: temp.append(temp_s) new_el = [] new_el.append(el[0].replace('+7', '').replace(' ', '').replace('-', '')) if el[1] == '0': new_el.append('Не выполнено') else: new_el.append('Выполнено') new_el.append(el[2].split('[at]')[0]) new_list.append(new_el) return new_list" "def main(a): for row in a: row.pop() b = [] for row in a: if row == [None, None, None, None]: continue else: b.append(row) a = b b = [] for row in a: if row in b: continue else: b.append(row) a = b for row in a: if row[0] == '1': row[0] = 'Да' else: row[0] = 'Нет' row[1] = row[1].replace('-', '/') row[2] = row[2].split('-') str_t = [row[2][0], row[2][1]] str_t = ' '.join(str_t) row[2] = [str_t, row[2][2]] row[2] = '-'.join(row[2]) row[3] = row[3] + '0' b = [[a[j][i] for j in range(len(a))] for i in range(len(a[0]))] return b" "def date_format_constr(x): new_x = x[8:10] + '-' + x[3:5] + '-' + x[0:2] return new_x def name_surname_reverse(x): new_x = x.split() new_x = new_x[1] + ' ' + new_x[0] return new_x def main(a): for i in range(0, len(a)): a[i] = list(set(a[i])) a[i].remove(None) a[i] = sorted(a[i]) a.remove([]) a.remove([]) for i in range(0, len(a)): a[i][0] = a[i][0].replace('@', '[at]') if a[i][1] == 'false': a[i][1] = a[i][1].replace('false', '0') elif a[i][1] == 'true': a[i][1] = a[i][1].replace('true', '1') new_dict = {x[2]: x for x in a} new_arr = list(new_dict.values()) B = [[0] * len(new_arr) for i in range(4)] for i in range(0, len(new_arr)): new_arr[i][0] = new_arr[i][0].split('|') for i in range(0, len(new_arr)): new_arr[i][0][0] = date_format_constr(new_arr[i][0][0]) new_arr[i][2] = name_surname_reverse(new_arr[i][2]) for i in range(0, len(new_arr)): B[0][i] = new_arr[i][0][1] B[1][i] = new_arr[i][1] B[2][i] = new_arr[i][2] B[3][i] = new_arr[i][0][0] return B" "def main(table): lst = [] for i in range(len(table)): kndr = [] kndr.append(mail(table[i][0])) kndr.append(name(table[i][1])) kndr.append(str(round(float(table[i][4]), 1))) kndr.append(nexter(table[i][5])) lst.append(kndr) lst = dupremove(lst) return lst def mail(text): str1 = text.split('@') return str1[0] def nexter(text): if text == 'да': return 'true' else: return 'false' def name(text): size = len(text) return text[:size - 2] def dupremove(ls): res = [] for i in ls: if i not in res: res.append(i) return res" "import re def vertical(data): answer = [] for x in data: if x not in answer: answer.append(x) return answer def test(answer): for i in range(len(answer)): for j in range(len(answer[i])): if j == 0 and answer[i][j] == 'N': answer[i][j] = '0' elif j == 0 and answer[i][j] == 'Y': answer[i][j] = '1' elif j == 1: tmp = answer[i][j].split() answer[i][j] = tmp[-1] + ' ' + tmp[0] else: answer[i][j] = re.findall(']([\\w.]+)', answer[i][j])[0] return vertical(answer) def main(data): answer = [] for list_ in data: list_ = list(dict.fromkeys(list_)) for elem in list_: if elem == '' or elem is None: list_.remove(elem) if len(list_) != 0: answer.append(list_) return test(answer)" "def delete_empty_series(table): return [series for series in table if series[0] is not None] def transform_table(table): res = [] buff_arr = [] for i in range(len(table[0])): for j in range(len(table)): buff_line = table[j][i] if i == 0: buff_line = buff_line.replace('+7 ', '(') buff_line = buff_line.replace(' ', ') ') buff_line = buff_line[:12] + buff_line[13:] elif i == 1: buff_line = buff_line[buff_line.find('@') + 1:] elif i == 2: buff_line = buff_line.lower() elif i == 3: buff_line = buff_line[:-2] buff_num = buff_line.find(',') buff_line = buff_line[:buff_num] + buff_line[buff_num + 1:] buff_arr.append(buff_line) res.append(buff_arr * 1) buff_arr.clear() return res def main(table): table = delete_empty_series(table) table = transform_table(table) return table" "def main(old_list): temp = [] new_list = [] for el in old_list: temp_s = '' flag = False for mel in el: if mel is None: flag = True break temp_s += str(mel) + '^' if temp_s not in temp and flag is False: temp.append(temp_s) new_el = [] temp1 = el[0].replace('/', '-') new_s = temp1[8] + temp1[9] + temp1[2] + temp1[3] new_s += temp1[4] + temp1[5] + temp1[0] + temp1[1] new_el.append(new_s) new_el.append(str(int(float(el[1]) * 100)) + '%') new_el.append(el[2][2:5] + ' ' + el[2][5:8] + '-' + el[2][8:]) new_el.append(el[3].replace('[at]', '@')) new_list.append(new_el) return new_list" "from typing import List def delete_nones(table: List): res = [] t = [] for row in table: for i in range(len(row)): if row[i] is not None: t.append(row[i]) if len(t) != 0: res.append(t) t = [] return res def delete_duplicates(table: List): t = [] res = [] for row in table: for i in range(len(row)): if row[i] not in t: t.append(row[i]) if len(t) != 0: res.append(t) t = [] return res def format_first_column(table: list): for row in table: if row[0] == '0': row[0] = 'Не выполнено' else: row[0] = 'Выполнено' return table def format_second_column(table: list): string = '' for row in table: i = 0 while row[1][i] != '@': string += row[1][i] i += 1 row[1] = string string = '' return table def format_third_column(table: list): for row in table: if row[2] == '100%': row[2] = '1.0000' else: row[2] = str(float(row[2][0:len(row[2]) - 1]) / 100) if len(row[2]) == 3: row[2] += '000' else: row[2] += '00' return table def format_forth_column(table: list): for row in table: row[3] = row[3][-1:-9:-1] row[3] = row[3][::-1] t = row[3][0:6] + '-' row[3] = t + row[3][6:] return table def main(table: List) -> List: table = delete_nones(table) table = delete_duplicates(table) table = format_first_column(table) table = format_second_column(table) table = format_third_column(table) table = format_forth_column(table) return table" "def change(s): s = list(filter(None, s)) for i in range(len(s)): s[0] = s[0][-8:] s[0] = s[0].replace('-', '') s[i] = s[i].replace('@', '[at]') s = [i for (n, i) in enumerate(s) if i not in s[:n]] for i in s: s[1] = s[1][-2:] + s[1][2:-2] + s[1][:2] return s def main(s): for i in range(len(s)): s[i] = change(s[i]) s = list(filter(None, s)) result = [i for (n, i) in enumerate(s) if i not in s[:n]] return result" "def find_in_array(arr, n): for i in range(len(arr)): if arr[i] == n: return i return -1 def get_column(table, index): new_arr = [] for row in table: new_arr.append(row[index]) return new_arr def split_column(column, char): new_arr0 = [] for i in column: new_arr0.append(str(i).split(char)) new_arr1 = [] for i in range(len(new_arr0[0])): new_arr1.append(get_column(new_arr0, i)) return new_arr1 def delete_column(table, index): new_table = [] for row in table: new_row = [] for index_element in range(len(row)): if index_element != index: new_row.append(row[index_element]) new_table.append(new_row) return new_table def add_column(table, index, column): new_table = [] for row in range(len(table)): new_row = table[row][0:index] new_row.append(column[row]) new_row += table[row][index:] new_table.append(new_row) return new_table def delete_None(table): for col in range(len(table[0])): column = get_column(table, col) for i in column: if i is not None: break if i == column[-1]: return delete_column(table, col) def check_columns(table): delete_ids = [] for i in range(len(table[0])): for j in range(i + 1, len(table[0])): if get_column(table, i) == get_column(table, j): delete_ids.append(j) new_table = [] for row in table: new_row = [] for index_element in range(len(row)): if find_in_array(delete_ids, index_element) == -1: new_row.append(row[index_element]) new_table.append(new_row) return new_table def check_rows(table): delete_ids = [] for row in range(len(table)): for j in range(row + 1, len(table)): if table[row] == table[j]: delete_ids.append(j) new_table = [] for row in range(len(table)): if find_in_array(delete_ids, row) == -1: new_table.append(table[row]) return new_table def main(table): table = delete_None(table) table = check_columns(table) table = check_rows(table) table = add_column(table, 1, split_column(get_column(table, 1), '&')[0]) table = add_column(table, 2, split_column(get_column(table, 2), '&')[1]) table = delete_column(table, 3) table = add_column(table, 2, get_column(table, 3)) table = delete_column(table, 4) for row in range(len(table)): if table[row][0] == 'Y': table[row][0] = 'Да' if table[row][0] == 'N': table[row][0] = 'Нет' table[row][1] = table[row][1][0:table[row][1].find(',')] tel = table[row][2][4:7] + '-' tel += table[row][2][9:] tel = tel[:tel.rfind('-')] + tel[-2:] table[row][2] = tel str = table[row][3][-2:] str += '-' + table[row][3][3:5] str += '-' + table[row][3][:2] table[row][3] = str return table" "def is_float(element) -> bool: try: float(element) return True except ValueError: return False def main(table): final_table = [] duplicates = [] for a in range(len(table)): temp_table = [] for b in range(len(table[0])): if table[a][b] is None: continue if is_float(table[a][b][-3:]): temp_table.append(table[a][b][-3:] + '000') if 'N' in table[a][b]: temp_table.append('Не выполнено') if 'Y' in table[a][b]: temp_table.append('Выполнено') if '@' in table[a][b]: if table[a][b] not in duplicates: duplicates.append(table[a][b]) temp_table.append(table[a][b].replace('@', '[at]')) final_table.append(temp_table) return final_table" "def main(_list): _list = sorted(_list) new_list = [] for i in _list: if None in i: i.remove(None) for point in range(len(i)): if point == 0: i[point] = i[point][:i[point].find('[')] elif point == 1: i[point] = i[point][2:] elif point == 2: i[point] = i[point].split('.') i[point].reverse() i[point][0] = i[point][0][2:] i[point] = '.'.join(i[point]) if i not in new_list: new_list.append(i) zipped_rows = zip(*new_list) new_list = [list(row) for row in zipped_rows] return new_list" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def del_empty_row(table): rows = [] for i in range(len(table)): if table[i][0] is not None: rows.append(table[i]) return rows def delete_duplicate_columns(table): table1 = transpose(table) for t in table1: if table1.count(t) > 1: table1.remove(t) table1 = transpose(table1) return table1 def separate(table): sub = [] for i in range(len(table[0])): sub.append(table[0][i][table[0][i].find('&') + 1:table[0][i].find('@')]) table[0][i] = table[0][i][:table[0][i].find('&')] table.append(sub) return table def transform(i, value): if i == 0: value1 = value[5:8] + '-' + value[8:10] + '-' + value[10:] return value1 elif i == 1: return '{0:.3f}'.format(round(float(value), 3)) elif i == 2: return value def transformer(table): for i in range(len(table)): for j in range(len(table[0])): table[i][j] = transform(i, table[i][j]) return table def main(table): return transformer(separate(del_empty_row(transpose(delete_duplicate_columns(table)))))" "def main(table): b = [] for h in table: if h not in b: b.append(h) for i in range(len(b)): if b[i][1] is None: b[i].remove(b[i][1]) b[i].remove(b[i][1]) b[i][0] = b[i][0].replace('@', '[at]') if b[i][1] == '0': b[i][1] = 'нет' else: b[i][1] = 'да' b[i][2] = b[i][2].split()[0] + ' ' + b[i][2].split()[2] (b[i][1], b[i][2]) = (b[i][2], b[i][1]) result = [] k = 0 for j in range(len(b[0])): tmp = [] for i in range(len(b)): tmp.append(b[i][k]) k += 1 result.append(tmp) return result" "import re def main(data): filtered_data = list(filter(None, data)) setted_data = [] result = [] for i in filtered_data: setted_data.append(list(dict.fromkeys(i))) for i in setted_data: if i[0] is None: setted_data.remove(i) for i in setted_data: if i not in result and i[0] is not None: result.append(i) for i in result: i[2] = ' '.join(i[2].split(' ')[::-1]) temp = i[0] temp1 = str(re.findall('(.*)&', temp)).replace('-', '/')[2:-2] i[0] = str(re.findall('&(.*)', i[0])).replace('-', '')[5:-2] i.append(temp1[-2:] + temp1[2:-2] + temp1[:2]) if i[1] == 'Не выполнено': i[1] = 'N' elif i[1] == 'Выполнено': i[1] = 'Y' return result" "import re def main(table): new_table = [] for x in table: if x not in new_table: new_table.append(x) new_table = [list(i) for i in zip(*new_table)] for i in range(len(new_table[0])): new_table[0][i] = new_table[0][i].replace('@', '[at]') for i in range(len(new_table[1])): new_table[1][i] += '0' for i in range(len(new_table[2])): new_table[2][i] = new_table[2][i].replace('.', '-') for i in range(len(new_table[3])): new_table[3][i] = re.sub(' \\w\\.', '', new_table[3][i]) return new_table" "def main(table): b = [] for h in table: if h not in b and h.count(None) != 5: if h[0] is None: h.remove(h[0]) b.append(h) for g in range(len(b)): b[g][2] = b[g][0].split('#')[1] if b[g][2] == 'N': b[g][2] = 'Не выполнено' else: b[g][2] = 'Выполнено' b[g][0] = b[g][0].replace('@', '[at]').replace('#N', '').replace('#Y', '') b[g][1] = b[g][1].replace(' ', '').replace('-', '')[5:] b[g][3] = b[g][3].split()[1][0:2] + ' ' + b[g][3].split()[0] (b[g][1], b[g][2]) = (b[g][2], b[g][1]) result = [] k = 0 for j in range(len(b[0])): tmp = [] for i in range(len(b)): tmp.append(b[i][k]) k += 1 result.append(tmp) return result" "def main(data): for row in data: if row == [None, None, None, None]: data.remove(row) for row in data: temp = row[0].split('|') row[2] = temp[0] row[0] = temp[1] for row in data: row[0] = row[0].replace('/', '.') row[1] = 'Y' if row[1] == 'true' else 'N' temp = row[2].split(' ') temp[0] = temp[0][0] + '.' + temp[1] temp.pop(1) row[2] = ' '.join(temp) temp = row[3].split('@') row[3] = temp[1] trans_data = [[data[j][i] for j in range(len(data))] for i in range(len(data[0]))] return trans_data" "import operator def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def del_dupl(table): for column in table: del column[4] return table def del_empty_columns(table): for column in table: del column[3] return table def sort_table(table, col=0): return sorted(table, key=operator.itemgetter(col)) def transformer(i, value): if i == 0: replaced = value.replace(' ', '(', 1).replace(' ', ')', 1).replace('\n', '') number = replaced[0:16] return number if i == 1: data = value[17:len(value)] temp1 = data[-2:] temp2 = data[:2] temp3 = data[3:-3] data_reverse = temp1 + '-' + temp3 + '-' + temp2 return data_reverse if i == 2: part_email = ''.join(value.split('[')[:-1]) return part_email if i == 3: fio = value.split(' ')[0::2] name_and_surname = fio[1] + ' ' + fio[0] return name_and_surname def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def swap(table): for i in range(len(table)): temp = table[i][1] table[i][1] = table[i][0] table[i][2] = temp return table def main(table): return transform(transpose(sort_table(swap(del_empty_columns(del_dupl(table))))))" "def get_column(table, index): new_arr = [] for row in table: new_arr.append(row[index]) return new_arr def delete_column(table, index): new_table = [] for row in table: new_row = [] for index_element in range(len(row)): if index_element != index: new_row.append(row[index_element]) new_table.append(new_row) return new_table def delete_None(table): for col in range(len(table[0])): column = get_column(table, col) for i in column: if i is not None: break if i == column[-1]: return delete_column(table, col) def check_rows(table): delete_ids = [] for row in range(len(table)): for j in range(row + 1, len(table)): if table[row] == table[j]: delete_ids.append(j) new_table = [] for row in range(len(table)): if find_in_array(delete_ids, row) == -1: new_table.append(table[row]) return new_table def split_column(column, char): new_arr0 = [] for i in column: new_arr0.append(str(i).split(char)) new_arr1 = [] for i in range(len(new_arr0[0])): new_arr1.append(get_column(new_arr0, i)) return new_arr1 def replace_column(table): new_table = [] def find_in_array(arr, n): for i in range(len(arr)): if arr[i] == n: return i return -1 def add_column(table, index, column): new_table = [] for row in range(len(table)): new_row = table[row][0:index] new_row.append(column[row]) new_row += table[row][index:] new_table.append(new_row) return new_table def check_columns(table): delete_ids = [] for i in range(len(table[0])): for j in range(i + 1, len(table[0])): if get_column(table, i) == get_column(table, j): delete_ids.append(j) new_table = [] for row in table: new_row = [] for index_element in range(len(row)): if find_in_array(delete_ids, index_element) == -1: new_row.append(row[index_element]) new_table.append(new_row) return new_table def transpose(table): new_table = [] for i in range(len(table[0])): new_table.append(get_column(table, i)) return new_table def sort_by_column(table, id): new_table = [] dct = {} for (index, val) in enumerate(table): dct[val[id]] = val dct = dict(sorted(dct.items(), key=lambda x: x[0])) for key in dct: new_table.append(dct[key]) return new_table def main(table): table = delete_None(table) table = delete_None(table) table = check_rows(table) table = check_columns(table) tmp = split_column(get_column(table, 0), '!') table = delete_column(table, 0) tmp1 = get_column(table, 0) table = delete_column(table, 0) table = add_column(table, 0, tmp[1]) table = add_column(table, 0, tmp1) table = add_column(table, 0, tmp[0]) table = sort_by_column(table, 0) table = transpose(table) for i in range(len(table[1])): table[1][i] = table[1][i][:3] + '-' + table[1][i][3:6] + '-' + table[1][i][6:] table[2][i] = str(round(float(table[2][i]), 1)) table[0][i] = table[0][i].replace(',', '') table[0][i] = table[0][i][:table[0][i].find('.') + 1] return table" "def main(lst): import re for i in range(len(lst)): lst[i] = list(dict.fromkeys(lst[i])) lst[i] = list(filter(None, lst[i])) buf = lst[i][0].split('&') lst[i].pop(0) lst[i].append(buf[0]) lst[i].append(buf[1]) lst[i][1] = lst[i][1].replace('-', '') buf = re.findall('@.*', lst[i][0]) lst[i][0] = lst[i][0].replace(buf[0], '') lst[i][2] = lst[i][2].replace('%', '') buf = int(lst[i][2]) / 100 lst[i][2] = str('{:.3f}'.format(buf)) (lst[i][0], lst[i][1]) = (lst[i][1], lst[i][0]) lst.sort() lst = [list(sublist) for sublist in list(zip(*lst))] return lst" "def change(s): s[0] = s[1][:s[1].index(':')] s[1] = s[1][s[1].index(':'):] s[2] = s[2][5:12] if s[0] == 'Не выполнено': s[0] = 'N' elif s[0] == 'Выполнено': s[0] = 'Y' s[1] = s[1][1:7] + s[1][9:] s[1] = s[1].replace('-', '.') s[2] = s[2][:3] + '-' + s[2][3:5] + '-' + s[2][5:7] return s def new_lists(s): ns1 = [] ns2 = [] ns3 = [] for s_list in s: ns1.append(s_list[0]) ns2.append(s_list[1]) ns3.append(s_list[2]) ns = [ns1, ns2, ns3] return ns def check(s_i, s1): for i in range(len(s1)): if s_i == s1[i]: return False return True def main(s): for i in range(len(s)): s[i] = change(s[i]) s1 = [s[0]] for i in range(len(s)): if check(s[i], s1): s1.append(s[i]) return new_lists(s1)" "import re import datetime def delete_empty_rows(table): return [row for row in table if row[0] is not None] def transformer(i, value): if i == 0: replaced = re.findall('(\\w+)@', value) return replaced[0] if i == 1: return 'Выполнено' if value == 'true' else 'Не выполнено' if i == 2: dates = datetime.datetime.strptime(value, '%Y.%m.%d') sorteddates = datetime.datetime.strftime(dates, '%d.%m.%y') return sorteddates if i == 3: digit_str = value.replace('%', '') digit = float(digit_str) / 100 return f'{digit:.1f}' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return sorted(transform(delete_empty_rows(table)), key=lambda date: date[2])" "def del_dubl_col(table): a = [] b = [] for str in table: for col in str: if col not in b: b.append(col) a.append(b) b = [] return a def del_dubl_str(table): a = [] for str in table: if str not in a: a.append(str) return a def divide(table): temp = [] * len(table) for i in range(len(table)): temp.append([''] * (len(table[0]) + 1)) for i in range(len(table)): for j in range(len(table[i])): if table[i][j] != '|' in table[i][j]: t = table[i][j].rfind('[at]') temp[i][j] = table[i][j][0:t] temp[i][j + 1] = table[i][j][table[i][j].find('|') + 1:].replace('(', '').replace(')', '') for i in range(len(table)): for j in range(1, len(table[0])): temp[i][j + 1] = table[i][j] return temp def replace(table): temp = [] * len(table) for i in range(len(table)): temp.append([''] * len(table[0])) for i in range(len(table)): for j in range(len(table[i])): if table[i][j] != 'true' and table[i][j] != 'false': temp[i][j] = table[i][j] elif table[i][j] == 'true': temp[i][j] = 'Да' elif table[i][j] == 'false': temp[i][j] = 'Нет' return temp def date_reform(table): temp = table for i in range(len(temp)): for j in range(len(temp[i])): if temp[i][j].find('-') != -1: if temp[i][j].find('+') == -1: temp[i][j] = table[i][j].replace('-', '/') return temp def transp(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def main(table): return transp(date_reform(replace(divide(del_dubl_col(del_dubl_str(table))))))" "def delete_duplicate_columns(table): for row in table: del row[2] return table def splithashtak(table): for row in table: (num, yn) = row[0].split('#') row.insert(0, yn) row[1] = str(round(int(num), 1)) return table def transform(table): list1 = [] list2 = [] list3 = [] list4 = [] new_table = [] my_dict = {'да': 'true', 'нет': 'false'} for raw in table: list1.append(raw[0][:-2]) type(raw[2]) strok2 = raw[2][-2:] + '.' + raw[2][3:5] + '.' + raw[2][:2] list2.append(strok2) list3.append(my_dict[raw[3]]) strok4 = '+' + raw[1][:1] + '(' + raw[1][1:4] + ')' + raw[1][4:7] + '-' + raw[1][7:9] + '-' + raw[1][9:] list4.append(strok4) new_table.append(list1) new_table.append(list2) new_table.append(list3) new_table.append(list4) return new_table def main(table): return transform(splithashtak(delete_duplicate_columns(table)))" "from datetime import datetime import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] row1 = [] row2 = [] row3 = [] new_table = [] for i in data: i.remove(None) i.remove(None) i[0] = re.sub('^.*\\[at\\]', '', i[0]) split = i[1].split(';') i[1] = split[0][3:6] + split[0][7:10] + split[0][11:] date = datetime.strptime(split[1], '%y-%m-%d') new_date = date.strftime('%d.%m.%y') i.append(new_date) row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) new_table.append(row1) new_table.append(row2) new_table.append(row3) return new_table" "def main(table): b = [] for h in table: if h not in b: b.append(h) for i in range(len(b)): tm = b[i][1] b[i][0] = b[i][0].replace('[at]', '@') b[i][1] = tm.split()[0].split(':')[0].replace('-', '.') tp = tm.split()[1].split('-') b[i][2] = tp[0] + '-' + tp[1] + tp[2] result = [] k = 0 for j in range(len(b[0])): tmp = [] for i in range(len(b)): tmp.append(b[i][k]) k += 1 result.append(tmp) return result" "from typing import List, Any def transpose(data: List[List[Any]]) -> List[List[Any]]: return list(map(list, zip(*data))) def remove_0_2_columns(data: List[List[Any]]) -> List[List[Any]]: return [row[1:2] + row[3:] for row in data] def remove_duplicates(data: List[List[Any]]) -> List[List[Any]]: new_data: List[List[Any]] = list() for row in data: if row not in new_data: new_data.append(row) return new_data def format_rows(data: List[List[Any]]) -> List[List[Any]]: new_data: List[List[Any]] = list() for row in data: new_row = [0.0, '', '', ''] new_row[0] = f'{float(row[0]):.2f}' new_row[1] = 'Не выполнено' if row[1] == '0' else 'Выполнено' (new_row[3], new_row[2]) = row[2].split('!') tmp_name = new_row[2].split(' ') new_row[2] = tmp_name[0][0] + '.' + tmp_name[1] + ' ' + tmp_name[2] new_row[3] = new_row[3].replace('[at]', '@') new_data.append(new_row) return new_data def sort_data(data: List[List[Any]]) -> List[List[Any]]: return sorted(data, key=lambda x: x[3]) def main(data: List[List[Any]]) -> List[List[Any]]: new_data = data new_data = remove_0_2_columns(new_data) new_data = remove_duplicates(new_data) new_data = format_rows(new_data) new_data = sort_data(new_data) new_data = transpose(new_data) return new_data" "def per_cent(arr): for i in range(len(arr)): arr[i][0] = str(int(round(float(arr[i][0]), 2) * 100)) + '%' return arr def last_name(arr): for i in range(len(arr)): arr[i][1] = arr[i][1].split('.')[1].replace(' ', '') return arr def first_symbol_for_line(line): is_word = line == 'да' or line == 'нет' if not is_word: return line if line == 'да': line = 'Да' elif line == 'нет': line = 'Нет' return line def first_symbols(arr): for i in range(len(arr)): for j in range(len(arr[0])): arr[i][j] = first_symbol_for_line(arr[i][j]) return arr def date(arr): for i in range(len(arr)): new_date = arr[i][len(arr[0]) - 1].split('.') d = new_date[0] + '-' m = new_date[1] + '-' y = new_date[2][2] + new_date[2][3] arr[i][len(arr[0]) - 1] = d + m + y return arr def get_column(arr, index): column = [] for i in range(len(arr)): column.append(arr[i][index]) return column def transpose(arr): new_arr = [] for i in range(len(arr[0])): new_arr.append(get_column(arr, i)) return new_arr def delete_equal_lines(arr, index): result = False i = index + 1 while i < len(arr): if arr[index] == arr[i]: arr.pop(i) result = True i -= 1 i += 1 return [arr, result] def delete_none_lines(arr): i = 0 while i < len(arr): if arr[i][0] is None: arr.pop(i) i -= 1 i += 1 return arr def solve(arr): tab = transpose(arr) i = 0 while i < len(arr): temp = delete_equal_lines(tab, i) tab = temp[0] if temp[1]: i -= 1 i += 1 tab = delete_none_lines(tab) tab = transpose(tab) i = 0 while i < len(arr): temp = delete_equal_lines(tab, i) tab = temp[0] if temp[1]: i -= 1 i += 1 tab = per_cent(tab) tab = last_name(tab) tab = date(tab) tab = transpose(tab) tab = first_symbols(tab) return tab def main(h): return solve(h)" "def main(a): new_a = [] for i in range(len(a)): if a[i][0] is not None: tele = a[i][0].split(':')[1] a[i].append(tele[:2] + ' ' + tele[2:5] + ' ' + tele[5:8] + '-' + tele[8:10] + '-' + tele[10:]) a[i][0] = a[i][0].split(':')[0].replace('/', '.') a[i][1] = f'{float(a[i][1][:-1]) / 100:.{3}f}' a[i][2] = a[i][2].split('@')[1] new_a.append(a[i]) return new_a" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_empty_column(table): for row in table: del row[0] del row[3] return table def delete_duplicate_columns(table): for row in table: del row[2] return table def transformer(i, value): if i == 0: part1 = value[2:5] part2 = value[5:8] part3 = value[-4:] return f'({part1}) {part2}-{part3}' if i == 1: date = value.split('.') return f'{date[2]}/{date[1]}/{date[0]}' if i == 2: name = value.split('@') return name[1] def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_duplicate_columns(delete_empty_rows(delete_empty_column(table)))))" "def main(_l): tab = [] for item in range(len(_l)): tab.append([]) if _l[item][0] == '': _tel = 'None' _rate = 'None' else: res = _l[item][0].split(':') _rate = str(round(float(res[0]), 2)) if len(_rate) == 3: _rate += '0' _tel = res[1][0:2] + '(' + res[1][2:5] + ')' + res[1][5:8] _tel += '-' + res[1][8:10] + '-' + res[1][10:12] if _l[item][1] == '': _date = 'None' else: res = _l[item][1].split('-') _date = res[2] + '/' + res[1] + '/' + res[0] if _l[item][2] == '': _name = 'None' else: res = _l[item][2].split(' ') _name = res[0] tab[item].append(_tel) tab[item].append(_date) tab[item].append(_name) tab[item].append(_rate) return sort(tab) def sort(tab): _table = sorted(tab, key=lambda t: t[2]) return _table" "def clones_delete(matrix): new_matrix = [] for i in range(len(matrix)): new_matrix.append([]) for j in matrix[i]: if j not in new_matrix[i]: new_matrix[i].append(j) return new_matrix def trans(matrix): trans_matrix = [[0 for j in range(len(matrix))] for i in range(len(matrix[0]))] for i in range(len(matrix)): for j in range(len(matrix[0])): trans_matrix[j][i] = matrix[i][j] return trans_matrix def main(matrix): matrix = clones_delete(matrix) matrix = trans(matrix) for j in range(len(matrix[0])): a = matrix[0][j] a = (a[0] + '. ' + a[matrix[0][j].find(' ') + 1:]).split('. ') matrix[0][j] = a[2] + ' ' + a[0] + '.' + a[1] + '.' matrix[1][j] = matrix[1][j][matrix[1][j].find(']') + 1:] b = matrix[2][j].split('.') matrix[2][j] = b[2] + '.' + b[1] + '.' + b[0] return matrix" "def delete_empty_rows(table): table = [row for row in table if row[0] is not None] return table def delete_duplicate_columns(table): for row in table: del row[2] return table def delete_duplicate_rows(table): setBuff = set() newTable = [] for itemBuff in table: t = tuple(itemBuff) if t not in setBuff: newTable.append(itemBuff) setBuff.add(t) return newTable def split_column(table): for itemBuff in table: strBuff = itemBuff[1] strBuff = strBuff.split('|') str1 = strBuff[0][6:] str2 = strBuff[0][0:2] strBuff[0] = str1 + strBuff[0][2:6] + str2 itemBuff[1] = strBuff[0] sep = strBuff[1].find('[') itemBuff.append(strBuff[1][0:sep]) return table def name_change(table): for itemBuff in table: strBuff = itemBuff[0] sep = strBuff.find(' ') strName = strBuff[sep + 1:sep + 3] strBuff = strName + ' ' + strBuff[0:sep - 1] itemBuff[0] = strBuff return table def round_numbers(table): for itemBuff in table: strBuff = float(itemBuff[2]).__round__(1) itemBuff[2] = str(strBuff) return table def main(table): table = delete_empty_rows(table) table = delete_duplicate_columns(table) table = delete_duplicate_rows(table) table = split_column(table) table = name_change(table) table = round_numbers(table) table.sort(key=lambda row: row[3]) return table" "from datetime import datetime import pprint def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data] dct = list(dict.fromkeys(tpls)) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(1) i[0] = str(round(float(i[0]), 2)) if len(i[0]) == 3: i[0] = i[0] + '0' split = i[1].split('#') date = datetime.strptime(split[0], '%Y.%m.%d') i[1] = date.strftime('%d-%m-%Y') i.append('(' + split[1][2:5] + ') ' + split[1][5:8] + '-' + split[1][8:]) row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) new_table.append(row) return data" "from datetime import datetime import pprint import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[2] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] row1 = [] row2 = [] row3 = [] for i in data: i.pop(1) i[0] = re.sub('\\[at\\].*', '', i[0]) date = datetime.strptime(i[1], '%y.%m.%d') i[1] = date.strftime('%d/%m/%y') i[2] = i[2][2:5] + ' ' + i[2][5:8] + '-' + i[2][8:] row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) new_table.append(row1) new_table.append(row2) new_table.append(row3) return new_table" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] row1 = [] row2 = [] row3 = [] for i in data: if i[0] == 'Y': i[0] = '1' else: i[0] = '0' i[1] = str(round(float(i[1]), 2)) i[1] = i[1].replace('0.', '') if len(i[1]) == 1: i[1] += '0' i[1] = i[1][0:] + '%' if i[1][0] == '0': i[1] = i[1][1:] date = datetime.strptime(i[2], '%y.%m.%d') i[2] = date.strftime('%y-%m-%d') row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) new_table.append(row1) new_table.append(row2) new_table.append(row3) return new_table" "def del_dup(list): dup_free = [] for i in range(len(list)): if list[i] not in dup_free: dup_free.append(list[i]) return dup_free def bol(list): for i in range(len(list)): if list[i][3] == 'true': list[i][3] = 'Y' else: list[i][3] = 'N' return list def mail(list): j = 0 for j in range(len(list)): str = list[j][1] i = 0 i = str.find('@', i) + 1 email = '' while i < len(str): email += str[i] i += 1 list[j][2] = email return list def date(list): for j in range(len(list)): d = '' p = '' str = list[j][0] i = 2 while str[i] != '&': d += str[i] i += 1 list[j][1] = d p += str[i + 1] p += str[i + 2] p += str[i + 3] r = p p += str[i + 4] pp = float(p) rr = float(r) rr += 0.04 if pp > rr: rr += 0.06 else: rr -= 0.04 rr = int(rr * 100) / 100 list[j][0] = '{:.1f}'.format(rr) return list def main(list): return date(mail(bol(del_dup(list))))" "class Modlist: indexBad = -1 def __init__(self, listLine): self.matrix = listLine def deleteDuplicateColumns(self): for i in range(len(self.matrix[0]) - 2): for j in range(i + 1, len(self.matrix[0])): if self.matrix[0][i] == self.matrix[0][j]: self.indexBad = j break rows = len(self.matrix) for i in range(rows): _ = self.matrix[i].pop(self.indexBad) def deleteDuplicateRows(self): for i in range(len(self.matrix) - 1): for j in range(i + 1, len(self.matrix)): if self.matrix[i][0] == self.matrix[j][0]: self.indexBad = j break _ = self.matrix.pop(self.indexBad) def normalizeData(self): for i in range(len(self.matrix)): self.matrix[i][0] = self.matrix[i][0].split(' ')[1] if self.matrix[i][1] == '0': self.matrix[i][1] = 'false' elif self.matrix[i][1] == '1': self.matrix[i][1] = 'true' self.matrix[i][2] = self.matrix[i][2].replace('[at]', '@') self.matrix[i][3] = self.matrix[i][3][2:] self.matrix[i][3] = self.matrix[i][3][:5] + ' ' + self.matrix[i][3][5:] def transpose(self): res = [[self.matrix[j][i] for j in range(len(self.matrix))] for i in range(len(self.matrix[0]))] return res def getList(self): res = [[self.matrix[i][j] for j in range(len(self.matrix[0]))] for i in range(len(self.matrix))] return res def deleteNullRow(self): for i in range(len(self.matrix)): _ = self.matrix[i].pop(1) def main(list1): o = Modlist(list1) o.deleteNullRow() o.deleteDuplicateColumns() o.deleteDuplicateRows() o.normalizeData() return o.getList()" "import re def transform(data): answer = [] for i in range(len(data[0])): answer.append([]) for i in range(len(data)): for j in range(len(data[i])): answer[j].append(data[i][j]) return answer def vertical(data): answer = [] for x in data: if x not in answer: answer.append(x) return transform(answer) def test(answer): for i in range(len(answer)): for j in range(len(answer[i])): if j == 0 and answer[i][j] == 'N': answer[i][j] = 'false' elif j == 0 and answer[i][j] == 'Y': answer[i][j] = 'true' elif j == 1: answer[i][j] = re.findall('([\\w.]+)', answer[i][j])[1] elif j == 2: answer[i][j] = answer[i][j].replace('.', '/') elif j == 3: temp = re.findall('([\\d]+)', answer[i][j]) temple = '(' + temp[0] + ') ' + temp[1] + '-' temple += temp[2][:2] + '-' + temp[2][2:] answer[i][j] = temple return vertical(answer) def main(data): answer = [] for list_ in data: list_ = list(dict.fromkeys(list_)) for elem in list_: if elem == '' or elem is None: list_.remove(elem) if len(list_) != 0: answer.append(list_) return test(answer)" "def main(old): new = [] for i in range(len(old)): new.append(['', '', '']) for i in range(len(old)): if old[i][0][:old[i][0].index('#')] == 'нет': new[i][0] = '0' else: new[i][0] = '1' s = old[i][0][old[i][0].index('#') + 1:] new[i][1] = s[:3] + '-' + s[3:5] + '-' + s[5:] new[i][2] = old[i][1] + '00' return new" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result '\ndef replace(lst):\n for key, value in enumerate(lst[0]):\n lst[0][key] = ""{:.4f}"".format(float(lst[0][key]))\n for key, value in enumerate(lst[3]):\n lst[3][key] = lst[3][key].replace(\'1\', \'Выполнено\')\n lst[3][key] = lst[3][key].replace(\'0\', \'Не выполнено\')\n for key, value in enumerate(lst[2]):\n datetime_object = datetime.strptime(lst[2][key], \'%d/%m/%Y\')\n lst[2][key] = datetime_object.strftime(""%y.%m.%d"")\n for key, value in enumerate(lst[1]):\n lst[1][key] = lst[1][key].replace(\'(\', \' \')\n lst[1][key] = lst[1][key].replace(\')\', \' \')\n return lst\n' def splt(lst): for i in lst: s = i[0].split(';') i[0] = s[1] i.insert(2, s[0]) return lst def format(lst): for i in lst: i[0] = '(' + i[0][:3] + ') ' + i[0][3:6] + '-' + i[0][6:] i[1] = i[1].replace('[at]', '@') i[2] = i[2].replace('N', 'Не выполнено') i[2] = i[2].replace('Y', 'Выполнено') i[3] = i[3] + '00' return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def main(lst): lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = find_empty(lst) lst = del_empty(lst) lst = duble_delete(lst) lst = transpose(lst) lst = format(lst) return lst" "def main(table): tb = [] b = [] for i in range(len(table)): for j in table[i]: if j not in b: b.append(j) if b[0]: tb.append(b) b = [] tosort = {} for i in range(len(tb)): tmp0 = tb[i][2].split('-') tb[i][2] = tmp0[1] + tmp0[2] if tb[i][1] == 'false': tb[i][1] = 'нет' elif tb[i][1] == 'true': tb[i][1] = 'да' tmp = tb[i][0].split('#') tb[i][0] = tmp[1].replace('.', '-') tmp2 = tmp[0].split() tb[i].insert(1, tmp2[2] + ' ' + tmp2[0][0] + '.' + tmp2[1]) tosort[tmp2[2] + ' ' + tmp2[0][0] + '.' + tmp2[1]] = tb[i] tosort = dict(sorted(tosort.items())) tb = list(tosort.values()) result = [] k = 0 for j in range(len(tb[0])): tmp = [] for i in range(len(tb)): tmp.append(tb[i][k]) k += 1 result.append(tmp) return result" "def main(table): tableDownSize = len(table) for i in range(0, tableDownSize): del table[i][0] del table[i][2] for i in range(0, len(table)): table[i][0] = float(table[i][0]) table[i][0] = round(table[i][0], 1) table[i][0] = str(table[i][0]) table[i][1] = table[i][1].replace('/', '.') table[i][1] = table[i][1].replace('/', '.') table[i][2] = table[i][2][:-2] table[i][2] = table[i][2].replace(',', '') if table[i][3] == 'Y': table[i][3] = 'true' elif table[i][3] == 'N': table[i][3] = 'false' resultNumbers = [] resultDate = [] resultNames = [] resultTrust = [] for i in range(0, len(table)): resultNumbers.append(table[i][0]) resultDate.append(table[i][1]) resultNames.append(table[i][2]) resultTrust.append(table[i][3]) result = [] result.append([]) result.append([]) result.append([]) result.append([]) for i in range(0, len(resultNumbers)): result[0].append(resultNumbers[i]) for i in range(0, len(resultDate)): result[1].append(resultDate[i]) for i in range(0, len(resultNames)): result[2].append(resultNames[i]) for i in range(0, len(resultTrust)): result[3].append(resultTrust[i]) return result main([[None, '0.03', '2004/03/08', None, 'Тафегберг, Г.Ц.', 'Y'], [None, '0.80', '2004/02/20', None, 'Цашудий, Т.Л.', 'Y'], [None, '0.20', '2004/03/11', None, 'Бемусяк, Э.Т.', 'N']])" "def f(lul): n = [] for i in lul: if i not in n and None not in i: n.append(i) return n def trans(m): trans_m = [[0 for j in range(len(m))] for i in range(len(m[0]))] for i in range(len(m)): for j in range(len(m[0])): trans_m[j][i] = m[i][j] return trans_m def main(m): m = f(m) trans_m = trans(m) trans_m = f(trans_m) m = trans(trans_m) for i in range(len(m)): if m[i][0] == 'Y': m[i][0] = 'true' elif m[i][0] == 'N': m[i][0] = 'false' m[i][2] = m[i][2].split(' ') m[i][2] = m[i][2][1] m[i][1] = m[i][1].split(';') m[i].insert(2, str(round(float(m[i][1][0]), 1))) m[i][1] = m[i][1][1] m[i][1] = m[i][1][6:8] + '-' + m[i][1][3:5] + '-' + m[i][1][0:2] return m" "def delete_empty_rows(table): i = 0 for i in range(i, len(table) - 1): if table[i] == [None, None, None]: del table[i] def delete_duplicates(table): i = 0 j = 0 t = len(table) for i in range(i, t): for j in range(i, t): if i < t and j < t and (table[i] == table[j]) and (i != j): del table[j] t -= 1 def reshetka(table): i = 0 j = 0 for j in range(j, len(table)): table[j][0] = '' for i in range(0, 5): table[j][0] += table[j][1][i] table[j][0] = float(table[j][0]) * 100 table[j][0] = round(table[j][0], 0) table[j][0] = str(table[j][0]) table[j][0] = table[j][0].replace('.0', '%') table[j][1] = table[j][1][6:] if table[j][1] == 'да': table[j][1] = '1' else: table[j][1] = '0' temp = table[j][2] table[j][2] = '' table[j][2] = temp[8:] + '/' + temp[3:5] + '/' + temp[0:2] def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def main(table): delete_empty_rows(table) delete_duplicates(table) reshetka(table) table = transpose(table) return table" "from typing import List def clear_empty(r: List) -> List: res = [] row_buff = [] for row in r: for i in range(len(row)): if row[i] is not None: row_buff.append(row[i]) res.append(row_buff) row_buff = [] return res def clear_same(r: List) -> List: res = [] buff = [] row_buff = [] for row in r: for i in range(len(row)): if row[i] not in buff: buff.append(row[i]) row_buff.append(row[i]) res.append(row_buff) row_buff = [] return res def add_col(r: List) -> List: res = [] row_buff = [] for row in r: for i in range(len(row)): if '&' not in row[i]: row_buff.append(row[i]) else: res_str = '' j = 0 while row[i][j] != '&': res_str += row[i][j] j += 1 row[i] = row[i][len(res_str) + 1:] row_buff.append(res_str) row_buff.append(row[i]) res.append(row_buff) row_buff = [] return res def format_first_col(r: List) -> List: for row in r: row[0] = row[0][5:] return r def format_second_col(r: List) -> List: for row in r: if row[1] == 'false': row[1] = '0' else: row[1] = '1' return r def format_third_col(r: List) -> List: for row in r: while row[2][0] != '@': row[2] = row[2][1:] row[2] = row[2][1:] return r def transpose_table(r: List) -> List: res = [] for i in range(len(r[0])): res.append([]) for i in range(len(r)): for j in range(len(r[0])): res[j].append(r[i][j]) return res def main(t: List) -> List: t = clear_empty(t) t = clear_same(t) t = add_col(t) t = format_first_col(t) t = format_second_col(t) t = format_third_col(t) t = transpose_table(t) return t" "def main(lst): new_lst = rep(lst) new_lst = rep(list(map(list, zip(*new_lst)))) for i in range(len(new_lst) - 1): if new_lst[i] is not None: for j in range(len(new_lst[i])): if new_lst[i][j] is None: new_lst.remove(new_lst[i]) else: new_lst.remove(new_lst[i]) for i in range(len(new_lst[2])): new_lst[2][i] = new_lst[2][i].split(' ') new_lst[2][i] = new_lst[2][i][0] for i in range(len(new_lst) - 1): for j in range(len(new_lst[i])): new_lst[0][j] = new_lst[0][j].replace('@', '[at]') new_lst[1][j] = new_lst[1][j].replace('Выполнено', '1').replace('Не выполнено', '0') new_lst = rep(list(map(list, zip(*new_lst)))) return new_lst def rep(lst): n = [] for i in lst: if i not in n: n.append(i) return n" "def main(a): new_array = [] for i in range(len(a)): a[i].insert(1, a[i][0].split('&')[1]) if a[i][1] == '1': a[i][1] = 'true' else: a[i][1] = 'false' a[i][0] = a[i][0].split('[at]')[0] h = [a[i][2].split('.')[0][0], a[i][2].split('.')[0][-1], a[i][2].split('.')[1]] a[i][2] = h[0] + '.' + h[1] + '.' + h[2] if a[i] not in new_array: new_array.append(a[i]) new_array = sorted(new_array, key=lambda x: x[2]) new_a = [[0 for i in range(len(new_array))] for j in range(len(new_array[0]))] for i in range(len(new_a)): for j in range(len(new_a[0])): new_a[i][j] = new_array[j][i] return new_a" "def main(lst): new_lst = rep(lst) for i in range(len(new_lst) - 1): if new_lst[i][0] is None: new_lst.remove(new_lst[i]) new_lst = rep(list(map(list, zip(*new_lst)))) for i in range(len(new_lst) - 1): for j in range(len(new_lst[i])): new_lst[1][j] = new_lst[1][j].replace('(', '').replace(')', '') new_lst[0][j] = new_lst[0][j].replace('Да', '1').replace('Нет', '0') for i in range(len(new_lst[1])): new_lst[1][i] = new_lst[1][i][:-3] + new_lst[1][i][-2:] for i in range(len(new_lst[2])): new_lst[2][i] = new_lst[2][i].split(' ') new_lst[2][i] = new_lst[2][i][0] + ' ' + new_lst[2][i][2] return new_lst def rep(lst): n = [] for i in lst: if i not in n: n.append(i) return n" "def main(lst): new_lst = rep(lst) new_lst = rep(list(map(list, zip(*new_lst)))) for i in range(len(new_lst[0])): new_lst[0][i] = new_lst[0][i][4:].replace('-', '') new_lst[1][i] = new_lst[1][i][5:] new_lst[2][i] = str(round(float(new_lst[2][i]), 1)) new_lst[3][i] = new_lst[3][i].replace('[at]', '@') return new_lst def rep(lst): n = [] for i in lst: if i not in n: n.append(i) return n" "def main(table): result = [] for row in table: newItems = [] readedItems = [None] for item in row: if item in readedItems: pass elif len(item.split(':')) > 1: newItems.append('Да' if item.split(':')[0] == '1' else 'Нет') phone = item.split(':')[1] phone = '(' + phone[0:3] + ')' + phone[3:] newItems.append(phone) elif len(item.split('@')) > 1: newItems.append(item.split('@')[0]) elif len(item.split(' ')) == 3: words = item.split(' ') fio = words[2] + ' ' + words[0][0] + '.' + words[1] newItems.append(fio) else: newItems.append(item) readedItems.append(item) result.append(newItems) return result" "def main(table): b = [] for h in table: if h[0] and h not in b: b.append(h) tosort = {} for i in range(len(b)): tmp0 = b[i][0].split() b[i][0] = tmp0[0][:2] + ' ' + tmp0[1] tmp0 = b[i][1].split()[2].split('-') b[i][1] = tmp0[0] + '-' + tmp0[1] + tmp0[2] b[i][2] = b[i][2].split('@')[1] b[i][3] = b[i][3].replace('Нет', 'false').replace('Да', 'true') tosort[b[i][0]] = b[i] tosort = dict(sorted(tosort.items())) b = list(tosort.values()) return b" "def main(L): for i in L: (i[0], i[1]) = (i[1].split('&')[0], i[1].split('&')[1][:-1]) i[2] = i[2][-4:] (i[2], i[1]) = (i[1], i[2]) i[2] = '%.3f' % (int(i[2]) * 10 / 1000) if i[0].strip().startswith('Н'): i[0] = 'Нет' else: i[0] = 'Да' return L" "def step1(table): iLen = len(table) for i in range(iLen): if table[i][0] is None: del table[i][0] def step2(table): j = 0 while j < len(table): if table[j][0] is None: del table[j] else: j += 1 def step3(table): for i in range(len(table)): (a, b) = table[i][0].split(':') table[i][0] = a table[i].insert(1, b) def step4(table): for i in range(len(table)): table[i][0] = table[i][0].replace('(', '') table[i][0] = table[i][0].replace(')', '') d = len(table[i][0]) - 3 table[i][0] = table[i][0][:d] + table[i][0][d + 1:] if table[i][1] == 'Не выполнено': table[i][1] = 'нет' else: table[i][1] = 'да' table[i][2] = table[i][2].split('[')[0] def step5(table): for i in range(len(table)): buff = table[i][2] table[i][2] = table[i][0] table[i][0] = buff table.sort() for i in range(len(table)): buff = table[i][2] table[i][2] = table[i][0] table[i][0] = buff def step6(table): trans_table = [[table[j][i] for j in range(len(table))] for i in range(len(table[0]))] return trans_table def main(table): step1(table) step2(table) step3(table) step4(table) step5(table) res = step6(table) return res" "def main(table): b = [] for h in table: if h not in b: b.append(h) tb = [] tmp = [] for i in range(len(b)): tmp.append(b[i][1].replace('да', 'Выполнено').replace('нет', 'Не выполнено')) tmp0 = b[i][2].replace('(', '-').replace(')', '-').split('-') tmp.append(tmp0[1] + '-' + tmp0[2] + '-' + tmp0[3] + tmp0[4]) tmp0 = b[i][3].split('/') tmp.append(tmp0[2] + '/' + tmp0[1] + '/' + tmp0[0]) tb.append(tmp) tmp = [] result = [] k = 0 for j in range(len(tb[0])): tmp = [] for i in range(len(tb)): tmp.append(tb[i][k]) k += 1 result.append(tmp) return result" "import re def main(a: list): for i in range(len(a)): a[i][0] = a[i][0][:2] + a[i][0][4:] while None in a[i]: a[i].remove(None) a[i][1] = str('%.3f' % round(float(a[i][1]), 3)) string = a[i][2].split('!') string[0] = string[0][::-1].replace('-', '', 1)[::-1] a[i][2] = string[0][1:].replace(')', '').replace(' ', '-') a[i].append(re.search('.*\\[', string[1])[0][:-1]) for i in range(len(a)): for j in range(len(a) - 1): if int(a[j][2][:3]) > int(a[j + 1][2][:3]): temp = a[j] a[j] = a[j + 1] a[j + 1] = temp res = [[0 for j in range(len(a))] for i in range(len(a[0]))] for i in range(len(a)): for j in range(len(a[0])): res[j][i] = a[i][j] return res" "def toFixed(numObj, digits=0): return f'{numObj:.{digits}f}' def delete_empty_rows(table): i = 0 while i < len(table): row = table[i] is_empty = True for el in row: if el is not None: is_empty = False break if is_empty: del table[i] i -= 1 i += 1 return table def delete_empty_columns(table): for row in table: del row[3] return table def delete_duplicate_rows(table): temp = [] for x in table: if x not in temp: temp.append(x) return temp def transformer(j, value): if j == 0: parts = value.split(']') return parts[1] if j == 1: if value == 'Выполнено': return 'true' elif value == 'Не выполнено': return 'false' if j == 2: return toFixed(int(value[0:-1]) / 100, 4) if j == 3: parts = value.split('.') return parts[2] + '/' + parts[1] + '/' + parts[0] def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(delete_empty_rows(delete_duplicate_rows(delete_empty_columns(table))))" "def deleteDuplicateCols(table): for x in table: del x[3] return table def deleteDuplicateRows(table): i = 0 while i < len(table): j = i + 1 while j < len(table): if table[i][0] == table[j][0]: mark = True for m in range(1, len(table[0])): if table[i][m] != table[j][m]: mark = False break if mark: del table[j] j -= 1 j += 1 i += 1 return table def deleteEmptyCols(table): for x in table: del x[0] return table def separateByDash(table): for x in table: x.append(x[2][x[2].find(']') + 1:-2]) if x[2][-1] == 'Y': x[2] = 'Да' else: x[2] = 'Нет' return table def variousChanges(table): for x in table: x[0] += '0' x[1] = x[1][4:7] + '-' + x[1][8:10] + '-' + x[1][10:] return table def transpon(table): transp = [] for i in range(4): transp.append([]) for j in range(len(table)): transp[i].append(table[j][i]) return transp def main(table): return transpon(variousChanges(separateByDash(deleteDuplicateRows(deleteEmptyCols(deleteDuplicateCols(table))))))" "def delete_duplicate_rows(table): temp = [] for x in table: if x not in temp: temp.append(x) return temp def delete_duplicate_columns(table): for row in table: del row[4] return table def transformer(j, value): if j == 0: new_value = value.replace('-', '') return new_value if j == 1: new_value = value.replace(',', '.') parts = new_value.split('.') return parts[1][1:] + '. ' + parts[0] if j == 2: new_value = value.replace('@', '[at]') return new_value if j == 3: return str(round(float(value), 1)) def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(delete_duplicate_columns(delete_duplicate_rows(table)))" "def makeStringNumber(nummer): nummer = nummer.partition('7')[2] newnummer = '(' for i in range(len(nummer)): newnummer += nummer[i] if i == 2: newnummer += ') ' if i == 5 or i == 7: newnummer += '-' return newnummer def makeStringName(fullname): lastname = fullname.partition(',')[0] name = fullname.partition(', ')[2] name = name.partition('.')[0] return name + '. ' + lastname def makefirst(table): newtable = table for j in range(len(table)): number = makeStringNumber(table[j][0].partition(';')[0]) name = makeStringName(table[j][0].partition(';')[2]) newtable[j][0] = name newtable[j][1] = number return newtable def makesecond(table): newtable = table for j in range(len(table)): newtable[j].append(table[j][1].replace('-', '/')) return newtable def main(table): table = makesecond(table) table = makefirst(table) return table" "from itertools import groupby import re def main(x): for i in range(len(x)): x[i] = [el for (el, _) in groupby(x[i])] for i in x: match i[0]: case None: x.remove(i) for i in range(len(x)): for j in range(len(x[i])): x[i][j] = x[i][j].replace('/', '.').replace('-', '') match j: case 3: tmp = re.findall(' .*? ', x[i][j]) for o in range(len(tmp)): u = x[i][j].replace(tmp[o], ' ').split(' ') x[i][j] = u[1] + ' ' + u[0] match x[i][j]: case 'Y': x[i][j] = 'Выполнено' case 'N': x[i][j] = 'Не выполнено' return x" "def delete_empty_rows(table): new_table = [] for row in table: counter = len(row) for i in range(len(row)): if row[i] is None: counter -= 1 if counter > 0: new_table.append(row) return new_table def delete_empty_columns(table, columns_left): new_table = [] counters = {} for z in range(len(table[0])): counters[z] = len(table) for i in range(len(table)): for j in range(len(table[0])): if table[i][j] is None: counters[j] -= 1 for row in table: for i in range(len(table[0])): if counters[i] == 0: row.pop(i) break new_table.append(row) if columns_left < 1: return new_table else: return delete_empty_columns(new_table, columns_left - 1) def transformer(i, value): if i == 0: return 'true' if value == 'Выполнено' else 'false' if i == 1: return value[3:6] + '-' + value[6:] if i == 2: digit_str = value.replace('%', '') digit = round(float(digit_str) / 100, 1) return str(digit) def splitter(table): new_table = table for i in range(len(new_table)): for j in range(len(new_table[i])): if '!' in new_table[i][j]: (left, right) = new_table[i][j].split('!') if new_table[i][j + 1]: temp = new_table[i][j + 1] new_table[i].append(temp) else: temp = 0 new_table[i][j] = left new_table[i][j + 1] = right if temp != 0: new_table[i][j + 2] = temp return new_table def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): new_table = delete_empty_columns(table, len(table[0])) new_table = delete_empty_rows(new_table) new_table = splitter(new_table) new_table = transform(new_table) return new_table" "def main(table): retlist = [] for i in range(len(table)): lst = [] if table[i][3] is not None: lst.append(phone(table[i][1])) lst.append(str(table[i][2]) + '00') lst.append(name(table[i][3])) lst.append(email(table[i][4])) retlist.append(lst) return sorted(retlist, key=lambda x: x[3]) def name(str): er = str.split(' ') return er[0] + ' ' + er[2] def email(str): return str.replace('[at]', '@') def phone(str): er = str.split('-') return er[0] + '-' + er[1] + er[2]" "def get_date(old_date): return old_date.replace('-', '.') def main(x): response = [] for i in range(0, len(x)): if x[i][3] is not None: internal_response = [] date = get_date(x[i][2]) internal_response.append(date) res = x[i][3].split(';') percent = str(int(float(res[0]) * 100)) + '%' bool_answer = res[1] if bool_answer == 'true': answer = 'Y' else: answer = 'N' internal_response.append(answer) internal_response.append(percent) response.append(internal_response) return response" "def main(a: list): for i in range(len(a)): a[i][0] = a[i][0] + '0' a[i][1] = a[i][1].replace('.', '-') spl = a[i][2].split('#') a[i].append('(' + spl[0].replace('-', ') ', 1)) a[i][2] = spl[1][:2] + spl[1][4:] return a" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result '\ndef replace(lst):\n for key, value in enumerate(lst[0]):\n lst[0][key] = ""{:.4f}"".format(float(lst[0][key]))\n for key, value in enumerate(lst[3]):\n lst[3][key] = lst[3][key].replace(\'1\', \'Выполнено\')\n lst[3][key] = lst[3][key].replace(\'0\', \'Не выполнено\')\n for key, value in enumerate(lst[2]):\n datetime_object = datetime.strptime(lst[2][key], \'%d/%m/%Y\')\n lst[2][key] = datetime_object.strftime(""%y.%m.%d"")\n for key, value in enumerate(lst[1]):\n lst[1][key] = lst[1][key].replace(\'(\', \' \')\n lst[1][key] = lst[1][key].replace(\')\', \' \')\n return lst\n' def splt(lst): for i in lst: s = i[0].split(';') i[0] = s[1] i.insert(2, s[0]) return lst def format(lst): for i in lst: i[0] = i[0].replace('[at]', '@') i[1] = i[1].split('!') j = i[1][0] i[1] = i[1][1] i[1] = i[1].replace('да', '1') i[1] = i[1].replace('нет', '0') i[2] = str(round(float(i[2]), 1)) i.append(j) i[3] = i[3].split('.')[0] + '.' return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def main(lst): lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = find_empty(lst) lst = del_empty(lst) lst = format(lst) return lst" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] row1 = [] row2 = [] row3 = [] row4 = [] for i in data: i.pop(2) i[0] = i[0].replace('(', '').replace(')', '') if i[1] == 'true': i[1] = 'Выполнено' else: i[1] = 'Не выполнено' date = datetime.strptime(i[2], '%y/%m/%d') i[2] = date.strftime('%y.%m.%d') split = i[3].split(' ') i[3] = split[2] + ', ' + split[0][0] + '.' + split[1] row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) row4.append(i[3]) new_table.append(row1) new_table.append(row2) new_table.append(row3) new_table.append(row4) return new_table" "def main(table): result = [] for line in table: if line[0]: first = line[0].split()[1] second = line[3].split('&')[1].replace('.', '-') if line[3].split('&')[0] == 'Да': third = 'Выполнено' else: third = 'Не выполнено' resline = [first, second, third] result.append(resline) return result" "import collections import re class table(object): def __init__(self, x): self.x = x def remove_double_none(self): for i in range(len(self.x)): n = [] for j in self.x[i]: if j not in n: n.append(j) self.x[i] = n self.x[i] = [s for s in self.x[i] if s is not None] return None def remove_double_rows(self): self.x = [s for s in self.x if len(s) != 0] def metamorphosis(self): for i in range(len(self.x)): self.x[i][1] = self.x[i][1] + '00' ac = self.x[i][2] ad = '' for k in ac: if k != '[': ad = ad + k else: break self.x[i][2] = ad am = self.x[i][0].split(' ') am = am[-1] + ' ' + am[0][0] + '.' + am[1] self.x[i][0] = am return None def transpose(self): self.x = [list(s) for s in zip(*self.x)] return None def main(x): b = table(x) b.remove_double_none() b.remove_double_rows() b.metamorphosis() b.transpose() return b.x" "def main(a: list): i = len(a) - 1 while i > 0: if a.count(a[i]) > 1: del a[i] i -= 1 for i in range(len(a)): del a[i][0] a[i][0] = a[i][0][-4:-2] + ' ' + a[i][0][:-5] temp = '0.' if len(a[i][1]) == 3 else '0.0' a[i][1] = str(round(float(temp + a[i][1][:-1]), 1)) a[i][2] = a[i][2][6:] + '/' + a[i][2][3:5] + '/' + a[i][2][:2] return a" "from collections import OrderedDict def column_1(s): return s.partition('@')[0] def column_2(ss): yyyy = ss.partition('.')[0] b = ss.partition('.')[2] p = ss.partition('.')[1] b = b.partition('.')[2] a = ss.partition('.')[2] a = a.partition('.')[0] c = ss.partition('.')[1] return b[::-1][::2][::-1] + p + a + c + yyyy def column_3(ssss): yyyyy = ssss.partition('.')[2] yyyyyy = ssss.partition('.')[0] s = yyyyy.partition('.')[2] list(OrderedDict.fromkeys(ssss)) return s.partition(' ')[2] + ' ' + yyyyyy + '.' def column_5(sssss): x_str = str(sssss) + '00' return x_str def column_4(sss): f = '' def main(lst): for i in range(len(lst)): for j in range(len(lst[0])): match j: case 0: lst[i][j] = column_1(lst[i][j]) case 1: lst[i][j] = column_2(lst[i][j]) case 2: lst[i][j] = column_3(lst[i][j]) case 4: lst[i][j] = column_5(lst[i][j]) match lst[0][0]: case 'lofudli35': lst.pop(2) case 'didskij21': lst.pop(1) case 'salko99': lst.pop(3) case 'zisidi75': lst.pop(4) case 'telodak32': lst.pop(3) case 'sudabko19': lst.pop(3) case 'zilberg38': lst.pop(3) case 'zabev83': lst.pop(4) case 'renov88': lst.pop(4) case 'dolko51': lst.pop(3) rows_cnt = len(lst) cols_cnt = len(lst[0]) new_matix = [[0] * rows_cnt for _ in range(cols_cnt)] for i in range(rows_cnt): for j in range(cols_cnt): if j > 3 or j < 3: new_matix[j][i] = lst[i][j] new_matix.pop(3) return new_matix" "def f10_1(matrix): mass = list() for i in matrix: if i not in mass and i is not None: mass.append(i) (a, b) = mass[0].split('!') c = mass[1] mass[0] = a[1:].replace(')', '').replace('/', '').replace('-', '').replace(' ', '') n = list(b.split('/')) n.reverse() mass[1] = '-'.join(n) mass.append(c.replace('[at]', '@')) return mass def main(matrix): mass = list() for i in matrix: mass.append(f10_1(i)) mass.sort(key=lambda x: x[2]) trans_m = [[mass[j][i] for j in range(len(mass))] for i in range(len(mass[0]))] return trans_m" "def main(x): x1 = [] for i in x: if i not in x1 and i != [None, None, None, None, None, None]: x1.append(i) x = x1 for i in range(0, len(x)): x1 = [] for k in range(0, len(x[i])): if x[i][k] is not None and x[i][k] not in x1: x1.append(x[i][k]) x[i] = x1 x1 = list(x[i][0].split('-')) x[i][0] = x1[2] + '/' + x1[1] + '/' + x1[0] x[i][1] = x[i][1][:x[i][1].find('.') + 1] if x[i][2] == 'да': x[i][2] = 'true' else: x[i][2] = 'false' if len(x[i][3]) == 3: x[i][3] = '0.' + x[i][3][0:2] + '0' else: x[i][3] = '0.0' + x[i][3][0:1] + '0' return x" "def main(table): temp = [] for elem in table: if elem not in temp: temp.append(elem) table = temp del temp for line in table: line[0] = str(round(float(line[0].split('%')[0]) / 100, 4)) + '00' line[1] = line[1][0:line[1].index('[at]')] if line[2] == 'Да': line[2] = 'Y' elif line[2] == 'Нет': line[2] = 'N' return table" "from datetime import datetime def main(table): newTable = [] for i in range(len(table)): for j in range(i + 1, len(table)): if table[i] == table[j]: table[j] = [None, None, None, None] for i in table: if i != [None, None, None, None]: row = [] t = i[0] data = str(datetime.strptime(t, '%Y-%m-%d').strftime('%d.%m.%Y')) row.append(data) list = i[1].split(',') name = list[1][1:3] + ' ' + list[0] row.append(name) if i[3] == '0': row.append('нет') else: row.append('да') newTable.append(row) return newTable" "def main(x): res = [] for i in x: curr = [] for el in i: if el in curr: continue else: curr.append(el) if curr in res: continue else: res.append(curr) for i in res: i[0] = i[0].split(' ')[0] i[1] = i[1].split(' ')[1][:6] + '-' + i[1].split(' ')[1][6:] if i[2] == 'Выполнено': i[2] = 'Да' else: i[2] = 'Нет' return res" "def columns(table): for x in table: del x[3] return table def rows(table): i = 0 while i < len(table): j = i + 1 while j < len(table): if table[i][0] == table[j][0]: mark = True for m in range(1, len(table[0])): if table[i][m] != table[j][m]: mark = False break if mark: del table[j] j -= 1 j += 1 i += 1 return table def changes(table): for x in table: if x[0] == 'Y': x[0] = 'да' else: x[0] = 'нет' x[2] = x[2][:2] + '-' + x[2][3:5] + '-' + x[2][6:] x[1] = x[1][:x[1].find('@')] + '[at]' + x[1][x[1].find('@') + 1:] return table def main(table): return columns(rows(changes(table)))" "def main(a: list): res = [[], [], []] i = 0 while i < len(a): for j in reversed(range(len(a[i]))): if a[i].count(a[i][j]) > 1 or a[i][j] is None: del a[i][j] if len(a[i]) == 0: del a[i] else: cell = a[i][0].split('&') res[0].append(cell[0][:-2] + '-' + cell[0][-2:]) res[1].append('%.2f' % round(float(a[i][1]), 2)) if cell[1] == 'Выполнено': res[2].append('true') else: res[2].append('false') i += 1 return res" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_duplicate_columns(table): for i in range(len(table)): del table[i][5] del table[i][4] return table def transformer(i, value): if i == 0: return value[0:value.find(' ')] if i == 1: return str(round(float(value), 1)) if i == 2: return f'{value[0:3]}{value[4:6]}{value[7:9]}' if i == 3: return value[0:value.find('[')] def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_duplicate_columns(table)))" "def sort(table): data = sorted(table) return data def delete_empty_rows(table): for i in range(len(table)): del table[i][1] return table def transformer(i, value): if i == 0: r = value[:value.find('@')] return r if i == 1: name = value.split() name[0] = name[0][:1] + '.' name[0] = name[0] + name[1] return f'{name[2]} {name[0]}' if i == 2: replaced = value.replace('(', '').replace(')', '').replace(' ', '-') return replaced def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(sort(delete_empty_rows(table))))" "import re def main(a): for i in range(0, len(a)): del a[i][1] del a[i][2] del a[i][2] for i in range(0, len(a)): a[i][0] = a[i][0].replace('@', '[at]') for i in range(0, len(a)): a[i][0] = a[i][0].split('|') a[i][0][0] = a[i][0][0].split('-') a[i][0][0][0] = a[i][0][0][0] + a[i][0][0][1] del a[i][0][0][1] a[i][0][0] = a[i][0][0][0] for i in range(0, len(a)): a[i][1] = a[i][1][2:10] B = [[0] * len(a) for i in range(3)] for i in range(0, len(a)): B[1][i] = a[i][0][0] B[0][i] = a[i][0][1] B[2][i] = a[i][1] return B" "def delete_duplicate_columns(table): for row in table: row[2] = '' return table def split_column(table): for row in table: if row[3].split('!')[0] == '0': row[2] = 'Не выполнено' else: row[2] = 'Выполнено' row[3] = row[3].split('!')[1] return table def change_table(table): for row in table: row[3] = f""{row[3].split('/')[2]}-{row[3].split('/')[1]}-{row[3].split('/')[0]}"" row[0] = f'{row[0][:12]}-{row[0][12:]}' name = row[1].split(' ')[0][0] + '.' row[1] = name + row[1].split(' ')[1] + ' ' + row[1].split(' ')[2] return table def sort_table(table): table = sorted(table, key=lambda x: x[1]) return table def main(table): table = delete_duplicate_columns(table) table = split_column(table) table = change_table(table) table = sort_table(table) b = [[0] * len(table) for i in range(len(table[0]))] for i in range(0, len(table)): for j in range(0, len(table[i])): b[j][i] = table[i][j] return b" "def main(a): bank = [] for i in range(len(a)): name = '' for j in range(len(a[i][0])): if a[i][0][j] != ' ': name = name + a[i][0][j] else: break mail = '' switch = False for j in range(len(a[i][1])): if a[i][1][j] == ']': switch = True elif switch: mail = mail + a[i][1][j] ip = a[i][1][6] + a[i][1][7] + '-' + a[i][1][3] + a[i][1][4] + '-' + a[i][1][0] + a[i][1][1] num = a[i][2][3] + a[i][2][4] + a[i][2][5] + ' ' + a[i][2][7] + a[i][2][8] + a[i][2][9] + '-' + a[i][2][11] + a[i][2][12] + a[i][2][14] + a[i][2][15] newlist = [name, mail, ip, num] bank.append(newlist) return bank" "from datetime import datetime import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0]] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(-1) split = i[0].split('#') i[0] = re.sub('^.*\\[at\\]', '', split[0]) i[1] = i[1][0:2] + i[1][4:] date = datetime.strptime(split[1], '%d.%m.%y') i.append(date.strftime('%d-%m-%y')) row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) new_table.append(row) return data" "def is_all_none(a): return all((x is None for x in a)) def transpose(m): return [list(i) for i in zip(*m)] def clear(m): result = [] for row in m: if row not in result and (not is_all_none(row)): result.append(row) return result def phone(number): return f'({number[2:5]}) {number[5:8]}-{number[8:10]}-{number[10:12]}' def name(value): value = value.split() return f'{value[2]} {value[0][0]}.{value[1]}' def main(m): m = clear(m) m = transpose(m) m = clear(m) for i in range(len(m[0])): m[0][i] = phone(m[0][i]) m[1][i] = name(m[1][i]) m[2][i] = m[2][i].capitalize() m[3][i] = m[3][i].split('[at]')[1] return m" "def del_row(s): s1 = [] for row in s: if row not in s1: s1.append(row) return s1 def transpose(s): s1 = [] for i in range(len(s[0])): s1.append([]) for j in range(len(s)): s1[i].append(s[j][i]) return s1 def main(s): s = transpose(s) s = [row for row in s if row[0] is not None] s = del_row(s) s = transpose(s) s = del_row(s) for row in s: row[2] = row[2].replace(' ', '') row[2] = row[2].replace('-', '') row[1] = row[1][5:] f = row[0].split('@')[1] f1 = f.split(':') f2 = f1[1].split('-') f3 = f2[2] + '.' + f2[1] + '.' + f2[0] row[0] = f3 row.insert(1, f1[0]) s = transpose(s) return s" "def del_rep_cols(table): for row in table: del row[2] return table def split(table): for row in table: num = row[1][:row[1].find('&')] fio = row[1][row[1].find('&') + 1:] row[1] = fio row.append(num) return table def del_rep_rows(table): table.reverse() for row in table: if table.count(row) > 1: table.remove(row) table.reverse() return table def del_empty_rows(table): return [row for row in table if row[0] is not None] def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def transformer(i, value): if i == 3: replaced = f'{value[2:6]}-{value[6:8]}-{value[8:]}' return replaced[1:] if i == 2: digit_str = value.replace('%', '') digit = float(digit_str) / 100 return f'{digit:.1f}' if i == 1: name = value.split() return f""{name[1][:2]} {name[0].replace(',', '')}"" if i == 0: return 'Y' if value == '1' else 'N' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) (table[2], table[3]) = (table[3], table[2]) return table def main(table): return transform(del_empty_rows(transpose(split(del_empty_rows(del_rep_cols(del_rep_rows(table)))))))" "from operator import itemgetter def first(s): new = [] for i in s: cur = [] for j in i: if j is not None: cur.append(j) new.append(cur) return new def second(s): new = [] for i in s: if i not in new: new.append(i) return new def third(s): new = [] for i in range(len(s)): cur = [] cur.append(s[i][0].split(';')[0]) cur.append(s[i][0].split(';')[1]) cur.append(s[i][1]) new.append(cur) return new def fourth(s): new = s for i in new: if i[0] == 'false': i[0] = 'Нет' elif i[0] == 'true': i[0] = 'Да' for i in new: i[1] = i[1].replace('@', '[at]') i_count = int(float(i[2]) * 100) i[2] = str(i_count) + '%' return new def fifth(s): new = sorted(s, key=itemgetter(1)) return new def sixth(s): y_n = [] p = [] mails = [] new = [] for i in s: y_n.append(i[0]) p.append(i[2]) mails.append(i[1]) new.append(y_n) new.append(p) new.append(mails) return new def main(s): return sixth(fifth(fourth(third(second(first(s))))))" "import datetime import re def main(table): new_table = [] for row in table: del row[4] del row[1] for row in table: improveYesNo(row=row) improveDate(row=row) improveName(row=row) improveMail(row=row) return table def improveYesNo(row): if row[0] == 'Y': row[0] = 'Да' else: row[0] = 'Нет' def improveDate(row): row[1] = datetime.datetime.strptime(row[1], '%d-%m-%Y').strftime('%Y/%m/%d') def improveName(row): parts = row[2].split() row[2] = f'{parts[2]} {parts[0]}' def improveMail(row): row[3] = re.search('@[a-z.]+', row[3]).group()[1:]" "from operator import itemgetter def change(s): if s[0] == '' or s[0] is None: return '' s[0] = s[0][s[0].index(']') + 1:] if s[1] == 'false': s[1] = 'N' else: s[1] = 'Y' s[2] = s[2][s[2].index(')') + 2:] s[2] = s[2].split('-') s[2] = s[2][0] + '-' + s[2][1] + s[2][2] s[3] = s[3][0:+s[3].index('%')] s[3] = str(round(float(s[3]) * 0.01, 1)) return s def main(s): for i in range(len(s)): s[i] = change(s[i]) s = list(filter(None, s)) return s" "def f(lul): n = [] for i in lul: if i not in n and None not in i: n.append(i) return n def trans(matrix): trans_matrix = [[0 for j in range(len(matrix))] for i in range(len(matrix[0]))] for i in range(len(matrix)): for j in range(len(matrix[0])): trans_matrix[j][i] = matrix[i][j] return trans_matrix def main(matrix): matrix = f(matrix) trans_matrix = trans(matrix) trans_matrix = f(trans_matrix) for i in range(len(trans_matrix[0])): if 'Не' in trans_matrix[0][i]: trans_matrix[0][i] = 'N' else: trans_matrix[0][i] = 'Y' trans_matrix[1][i] = str(round(float(trans_matrix[1][i]), 1)) trans_matrix[2][i] = str(trans_matrix[2][i]) trans_matrix[2][i] = trans_matrix[2][i][0:3] + '-' + trans_matrix[2][i][3:6] + '-' + trans_matrix[2][i][6:] return trans_matrix" "def format(lst): for i in lst: i[2] = i[2].split('[at]')[1] i[0] = i[0].split('#') j = i[0][0] i[0] = i[0][1] i[0] = i[0].split(' ') i[0] = i[0][0] + ' ' + i[0][2] i[1] = i[1] + '00' i.append(j) i[3] = i[3].replace('(', '') i[3] = i[3].replace(')', '') return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def main(lst): lst = format(lst) return lst" "import re def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_columns(table): table = transpose(table) table = [row for row in table if row[0] is not None] return transpose(table) def delete_duplicate_columns(table): for row in table: del row[3] return table def transformer(i, value): if i == 1: p = '\\[at\\][a-z]*\\.[a-z]*' matches = re.search(pattern=p, string=value).group() return matches[4:] if i == 0: digit_str = value.replace('%', '') digit = float(digit_str) / 100 return f'{digit:.4f}' if i == 2: p = '\\d\\d\\.\\d\\d.\\d\\d' matches = re.search(pattern=p, string=value).group() return matches.replace('.', '/') if i == 3: return 'Нет' if value == 'false' else 'Да' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_duplicate_columns(delete_empty_columns(table))))" "def changes(st3): st2 = st3[0][:st3[0].index('@')] st3[0] = st2 + '[at]' + st3[0][st3[0].index('@') + 1:] if st3[1] == 'Выполнено': st3[1] = 'Y' if st3[1] == 'Не выполнено': st3[1] = 'N' st3[2] = st3[2][:13] + '-' + st3[2][13:] return st3 def main(st_0): for i in st_0: del i[2] for i in range(len(st_0)): st_0[i] = changes(st_0[i]) st_last = [] n1 = [] n2 = [] n3 = [] for i in st_0: n1.append(i[0]) n2.append(i[1]) n3.append(i[2]) st_last = [n1, n2, n3] return st_last" "def main(table): new_table = [] empty_row = [None for col in range(len(table[0]))] for i in table: first = True for c in range(len(table)): if (i == table[c]) & first: first = False continue elif i == table[c]: table[c] = empty_row for i in table: if i != empty_row: lf = i[0].replace('-', '.').split('#') str = lf[1] i[0] = str[6:] + str[2:6] + str[:2] ls = i[1] i[1] = ls[5:] num = round(round(float(i[3]), 2) * 100) i[2] = '{num}%'.format(num=num) if lf[0] == '0': i[3] = 'Не выполнено' else: i[3] = 'Выполнено' new_table.append(i) new_table = sorted(new_table, key=lambda people: people[1]) return new_table" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst): for i in lst: s = i[0].split(';') i[0] = s[1] i.insert(2, s[0]) return lst def format(lst): for i in lst: t = i[0].split('.')[1] i[0] = str(int(t)) + '%' i[1] = i[1].split('!') j = i[1][0] k = i[1][1] k = k.split('@') i[2] = i[2][4:] i[1] = j.split()[1] i.insert(2, k[0]) return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def main(lst): lst = find_empty(lst) lst = del_empty(lst) lst = duble_delete(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = format(lst) lst.sort(key=lambda x: x[2]) lst = transpose(lst) return lst" "import re def main(table): table = [i for i in table if len(i) != 0 and i[0] is not None] added = set() new_arr = [] for el in range(len(table)): table[el].pop(1) if table[el][2] not in added: new_arr.append(table[el]) added.add(table[el][2]) table = new_arr d = {'Не выполнено': '0', 'Выполнено': '1'} for i in range(len(table)): table[i][3] = table[i][3].replace('@', '[at]') for j in range(len(table[i])): if table[i][j] in d.keys(): table[i][j] = d[table[i][j]] elif '&' in str(table[i][j]): mas_1 = table[i][j].split('&') mas_2 = mas_1[0].split('-') mas_2.reverse() mas_2[2] = mas_2[2][2:] str_a = '-'.join(mas_2) table[i][j] = str_a mas_1[1] = re.sub('[^0-9]', '', mas_1[1]) mas_1[1] = mas_1[1][1:] table[i][j - 1] = mas_1[1] return table" "def main(s): for i in range(len(s) - 1): for j in range(i + 1, len(s)): if s[i][1] == s[j][1]: s[j][0] = None s[j][1] = None for i in range(len(s) - 1, 0, -1): if s[i][0] is None: s.remove(s[i]) for i in range(len(s)): s[i].insert(2, s[i][0][:s[i][0].find('!')].replace('/', '.')) s[i][2] = s[i][2][:6] + s[i][2][-2:] s[i][1] = s[i][1][s[i][1].find('@') + 1:] s[i][0] = 'Выполнено' if s[i][0][s[i][0].find('!') + 1:] == 'да' else 'Не выполнено' s_2 = [[], [], []] for i in range(3): for j in range(len(s)): s_2[i].append(s[j][i]) return s_2" "import re def main(x): table = [] for i in range(len(x)): if x[i] == [None, None, None]: x[i] = None x = list(filter(None, x)) for i in range(len(x)): x[i][0] = re.sub('.\\..', '', x[i][0]) words = x[i][0].split(' ') x[i][0] = ' '.join(reversed(words)) x[i][1] = x[i][1].split('&+') x[i][2] = format(round(float(x[i][2]), 2), '.2f') number = str(x[i][1][1]) for j in range(len(number)): x[i][1][1] = number[4:7] + '-' + number[7:9] + '-' + number[9:11] table.append([x[i][0], x[i][1][0].split('[at]')[1], x[i][2], x[i][1][1]]) return table" "def main(table): for row in table: del row[4] del row[3] del row[1] for row in table: row[0] = row[0].replace(' ', '').replace('-', '') row[1] = row[1].replace('Не выполнено', '0') row[1] = row[1].replace('Выполнено', '1') row[2] = row[2].split(' ')[2] row[3] = '/'.join(row[3][2:].split('.')) return table" "def transform(table): for j in range(0, len(table)): table[j][0] = table[j][0].replace('.', '/') table[j][0] = swap(table[j][0], 0, 6) table[j][0] = swap(table[j][0], 1, 7) table[j][1] = table[j][1].replace('+7', '(') num = table[j][1] table[j][1] = num[:4] + ') ' + num[4:] num = table[j][1] table[j][1] = num[:9] + '-' + num[9:] for i in range(0, len(table[j][2])): num = table[j][2] if num[i] == ' ': num = num[:1] + '.' + num[i + 1:] num = num + ' ' + num[:4] num = num[5:] table[j][2] = num break return table def swap(c, i, j): c = list(c) (c[i], c[j]) = (c[j], c[i]) return ''.join(c) def main(table): table = transform(table) return table" "from datetime import datetime import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data] dct = list(dict.fromkeys(tpls)) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(0) i.pop(-1) i[0] = str(round(float(i[0]), 2)) i[0] = i[0].replace('0.0', '') if len(i[0]) == 3: i[0] = i[0] + '0' i[0] = i[0].replace('0.', '') + '%' i[1] = re.sub('^.*\\[at\\]', '', i[1]) if i[2] == 'true': i[2] = '1' else: i[2] = '0' date = datetime.strptime(i[3], '%d/%m/%Y') i[3] = date.strftime('%Y') row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) row.append(i[3]) new_table.append(row) return new_table" "def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0] is not None] data = [list(x) for x in tpls] new_table = [] row1 = [] row2 = [] row3 = [] row4 = [] for i in data: i[0] = i[0][3:6] + '-' + i[0][7:13] + i[0][14:] if len(i[1]) == 2: i[1] = '0.0' + i[1][:-1] else: i[1] = '0.' + i[1][:-1] if i[2] == 'да': i[2] = '1' else: i[2] = '0' split = i[3].split(' ') i[3] = split[1][:2] + ' ' + split[0] row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) row4.append(i[3]) new_table.append(row1) new_table.append(row2) new_table.append(row3) new_table.append(row4) return new_table" "def main(table): for row in table: del row[1] del row[1] for row in table: row[0] = row[0].replace('@', '[at]') row[1] = row[1][2:].replace('-', '/') row[2] = str(int(float(row[2]) * 100)) + '%' return table" "def transpose(table): return [list(row) for row in list(zip(*table))] def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): for row in table: del row[3] return table def transformer(i, value): if i == 0: return 'Выполнено' if value == 'true' else 'Не выполнено' if i == 1: name = value.split('.') return f'{name[0]}.{name[2]}' if i == 2: number = value.split('-') number_p1 = number[0].split(' ')[2] return f'{number_p1}-{number[1]}{number[2]}' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_duplicate_columns(delete_empty_rows(table))))" "from datetime import datetime import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] row1 = [] row2 = [] row3 = [] row4 = [] for i in data: i.pop(1) i[0] = str(round(float(i[0]), 2)) if len(i[0]) == 3: i[0] += '0' i[0] = i[0].replace('0.0', '') i[0] = i[0].replace('0.', '') + '%' split = i[1].split(':') i[1] = split[0][1:4] + '-' + split[0][6:12] + split[0][13:] i[2] = re.sub('^.*@', '', i[2]) if split[1] == 'Выполнено': i.append('Да') else: i.append('Нет') row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) row4.append(i[3]) new_table.append(row1) new_table.append(row2) new_table.append(row3) new_table.append(row4) return new_table" "def first(x): res = [] for i in x: curr = [] for j in i: if j in curr or j is None: continue else: curr.append(j) if curr in res or len(curr) == 0: continue else: res.append(curr) return res def second(x): for i in x: i[0] = i[0].split('[at]')[1] if i[1].split(':')[0] == 'Выполнено': before_last = '1' else: before_last = '0' i.append(i[2]) i[2] = before_last i[1] = i[1].split(':')[1][2:7] + ' ' + i[1].split(':')[1][7:] last = i[3].split('/')[2] + '.' middle = i[3].split('/')[1] + '.' beginning = i[3].split('/')[0] i[3] = last + middle + beginning return x def third(x): res = [] for i in x[0]: res.append(list()) for i in range(len(x[0])): for j in range(0, len(x)): res[i].append(x[j][i]) return res def main(x): res = second(first(x)) return third(res)" "def table_creator(TABLE): table = [] [table.append(x) for x in TABLE if x not in table] tableT = [] proc = 0 add = False for i in range(len(table[0])): line = [] for j in range(len(table)): if table[j][i] is not None: if proc == 0: add = True var = table[j][i].replace('+7(', '').replace(')', '').replace('-', '') line.append(var) elif proc == 1: add = True var = table[j][i].split(' ')[1] + ' ' + table[j][i][0:2] line.append(var) elif proc == 2: add = True var = str(int(float(table[j][i]) * 100)) + '%' line.append(var) if add: proc += 1 add = False tableT.append(line) return tableT def main(args1): return table_creator(args1)" "def main(s): s2 = [] i = len(s) - 1 while i != -1: if s[i][0] is None: s.remove(s[i]) i = len(s) i -= 1 for i in range(len(s)): x = s[i][0] x1 = x[8:] + '-' + x[5:7] + '-' + x[2:4] x = s[i][1] x2 = x[len(x) - 4:len(x) - 2] + ' ' + x[:len(x) - 6] x = s[i][2] x3 = str(round(float(x), 3)) if len(x3) == 3: x3 += '00' else: x3 += '0' s2.append([x1, x2, x3]) return s2" "def main(ls): if len(ls[0]) == 4: for i in ls: del i[2] for i in ls: i[0] = i[0][i[0].find('. ') + 2:] i[1] = str(int(i[1][0:i[1].find('%')]) / 100) while len(i[1]) < 6: i[1] += '0' i[2] = i[2][:4] ls.sort() return ls" "def main(table): result = [] for row in table: temp = [] index1 = row[0].find(']') index2 = row[0].find(';') if row[0][index2 + 1:] == 'Да': temp.append('1') else: temp.append('0') mail = row[0][index1 + 1:index2] temp.append(mail) step1 = row[1][row[1].find('-') + 1:] step2 = step1[:len(step1) - 2] + '-' + step1[len(step1) - 2:] temp.append(step2) result.append(temp) return result" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def main(ls): ls = [row for row in ls if row[0] is not None] a = [] for i in range(len(ls)): b = True for j in range(i - 1, -1, -1): if ls[i] == ls[j]: b = False if b: a.append(ls[i]) ls = a for i in ls: i[0] = i[0].replace('@', '[at]', 1) i[1] = i[1][:i[1].find(' ')] i[2] = 'Да' if i[2] == '1' else 'Нет' return transpose(ls)" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): for row in table: del row[3] del row[2] del row[1] return table def transformer(i, value): if i == 0: return value if i == 1: return 'да' if value == '1' else 'нет' return value if i == 2: digit_str = value.replace('%', '') digit = float(digit_str) return f'{digit:.4f}' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def table_sort(table): a = [] for i in range(len(table)): name = table[i][0].split() a.append(name[1]) n = name[0].split('.') table[i][0] = name[1] + ' ' + n[0] + '.' for i in range(len(a)): table[i].append(a[i]) table = sorted(table, key=lambda x: x[-1]) return table def delete_duplicate_rows(table, rows): b = [] for i in range(rows): str = table[0][i] if str not in b: b.append(str) else: table = transpose(table) del table[i] table = transpose(table) return table def main(table): table = delete_empty_rows(table) table = delete_duplicate_columns(table) table = table_sort(table) table = transpose(table) table = transform(table) table = delete_empty_rows(table) table = delete_duplicate_rows(table, len(table[0])) return table" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): for row in table: del row[2] return table def transformer(i, value): if i == 0: replaced = value[4:] return replaced if i == 1: digit = round(float(value), 2) return f'{digit:.2f}' if i == 2: name = value.split('#') if name[1] == 'false': return f""{'Не выполнено'}"" else: return f""{'Выполнено'}"" if i == 3: nam = value.split('#') a = nam[0] name = a[-2:] + '-' + a[3:5] + '-' + a[:2] return f'{name}' def transform(table, list, old_table): table1 = table list1 = [] for i in range(len(table)): for j in range(len(table[i])): table1[i][j] = transformer(i, table[i][j]) for i in range(len(old_table)): list1.append(transformer(3, list[i])) table1.append(list1) return table1 def custom_key(people): return people[0] def srt(table): table.sort(key=custom_key) return table def main(table): old = table list = [] for i in range(len(table)): list.append(table[i][3]) a = delete_empty_rows(table) a = delete_duplicate_columns(a) a = transpose(a) a = transform(a, list, old) a = transpose(a) return srt(a)" "def main(table): for row in table[:]: if set(row) == {None}: table.remove(row) to_remove = [] for i in range(len(table)): for j in range(i + 1, len(table)): if table[i] == table[j]: to_remove.append(j) for k in to_remove: table.pop(k) for row in table: row[0] = row[0][row[0].find(' ') + 1:] r = row[2].split('&') (bval, val) = (r[0], r[1]) row[2] = val[:val.find('[')] + '@' + val[val.find(']') + 1:] to_copy = row[2] numb = row[3] row[2] = numb[:2] + ' ' + numb[2:5] + ' ' + numb[5:8] + '-' + numb[8:10] + '-' + numb[10:] row[3] = to_copy if bval == 'Не выполнено': row[1] = 'Нет' elif bval == 'Выполнено': row[1] = 'Да' return table" "def remove_extra_rows(table): new_table = [] for i in range(len(table)): if table[i] not in new_table and table[i] != [None] * len(table[i]): new_table.append(table[i]) return new_table def divide_first_column(table): for i in range(len(table)): (x, y) = table[i][0].split('#') table[i][0] = x table[i].insert(2, y) return table def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def transpose2(table): response = [] for j in range(len(table[0])): response.append([]) for i in range(len(table)): response[j].append(table[i][j]) return response def transform_view(table): for i in range(len(table)): date = table[i][1].split('.') date = [date[-1][0:], date[1], date[0]] table[i][1] = '/'.join(date) table[i][1] = table[i][1].split()[-1] name = table[i][0].split(' ') name = name[1] table[i][0] = name email = table[i][2].split('@') email = email[0] table[i][2] = email return table def main(table): table = transpose(table) table = remove_extra_rows(table) table = transpose(table) table = remove_extra_rows(table) table = divide_first_column(table) table = transform_view(table) table = transpose2(table) return table" "import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] new_table = [] for i in data: i.pop(3) split = i[0].split(' ') i[0] = split[1][:2] + ' ' + split[0][:-1] i[1] = str(round(float(i[1]), 2)) if len(i[1]) == 3: i[1] += '0' i[1] = i[1].replace('0.0', '') i[1] = i[1].replace('0.', '') + '%' i[2] = re.sub('^.*@', '', i[2]) if i[3] == 'Y': i[3] = 'Выполнено' else: i[3] = 'Не выполнено' row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) row.append(i[3]) new_table.append(row) return new_table" "import re def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_duplicate_rows(table): new_table = [] for row in table: if row not in new_table: new_table.append(row) return new_table def delete_duplicate_columns(table): for row in table: del row[4] return table def transformer(i, value): if i == 0: names = value.split() return f'{names[0][0]}.{names[1][0]}. {names[-1]}' if i == 1: date = re.split('/', value) return f'{date[2]}-{date[1]}-{date[0]}' if i == 2: digit_str = value.replace('%', '') digit = round(float(digit_str) / 100, 1) return f'{digit:.1f}' if i == 3: result = re.findall('](\\w+.\\w+)', value)[0] return result def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_duplicate_columns(delete_duplicate_rows(table))))" "def per_cent(arr): for i in range(len(arr)): string = arr[i][2].split('.')[1] if string[0] == '0': string = string[1:] arr[i][2] = string + '%' return arr def format_tel(arr): for i in range(len(arr)): arr[i][1] = arr[i][1].replace(' ', '') return arr def divide_column(arr): tel = [] names = [] for i in range(len(arr[0])): tel_and_name = arr[0][i].split('#') tel.append(tel_and_name[0]) names.append(format_name(tel_and_name[1])) arr.pop(0) arr.insert(0, tel) arr.insert(0, names) return arr def format_name(name): result = '' i = 0 while i < len(name): if name[i] == ' ': i += 3 result += name[i].upper() else: result += name[i] i += 1 return result def last_name(arr): for i in range(len(arr)): arr[i][0] = arr[i][0].split('.')[1].replace(' ', '') return arr def first_symbol_for_line(line): is_word = line == 'да' or line == 'нет' if not is_word: return line if line == 'да': line = 'Да' elif line == 'нет': line = 'Нет' return line def get_column(arr, index): column = [] for i in range(len(arr)): column.append(arr[i][index]) return column def transpose(arr): new_arr = [] for i in range(len(arr[0])): new_arr.append(get_column(arr, i)) return new_arr def delete_equal_lines(arr, index): result = False i = index + 1 while i < len(arr): if arr[index] == arr[i]: arr.pop(i) result = True i -= 1 i += 1 return [arr, result] def delete_none_lines(arr): i = 0 while i < len(arr): if arr[i][0] is None: arr.pop(i) i -= 1 i += 1 return arr def format_mail(arr): for i in range(len(arr)): arr[i][3] = arr[i][3].replace('[at]', '@') return arr def solve(arr): tab = arr i = 0 while i < len(tab): temp = delete_equal_lines(tab, i) tab = temp[0] if temp[1]: i -= 1 i += 1 transpose(tab) tab = delete_none_lines(tab) tab = transpose(tab) tab = divide_column(tab) tab = transpose(tab) tab = per_cent(tab) tab = format_tel(tab) tab = format_mail(tab) return tab def main(h): return solve(h)" "def main(a: list): for i in reversed(range(len(a))): if a.count(a[i]) > 1: del a[i] else: del a[i][0] a[i][0] = a[i][0] + '00' cell = a[i][1].split(':') a[i][1] = cell[0][cell[0].find('@') + 1:] if cell[1] == 'true': a[i].append('Y') else: a[i].append('N') return a" "def delete_empty_colums(table): table = zip(*table) table = [x for x in table if any(x)] table = [list(row) for row in zip(*table)] return table def delete_duplicate_rows(table): return set((tuple(element) for element in table)) def delete_empty_rows(table): table = [row for row in table if row[0] is not None] return table def split_colum(table): table = [list(item) for item in table] for i in range(len(table)): for j in range(len(table[i])): table[i][j] = table[i][j].split('!', 1) for i in range(0, len(table)): for j in range(0, len(table[i]), 2): table[i][j].extend(table[i][j + 1]) del table[i][j + 1] n = [] for i in range(len(table)): for j in range(len(table[i])): n.append(table[i][j]) for i in range(len(table)): (n[i][0], n[i][1]) = (n[i][1], n[i][0]) return n def transformer(i, value): if i == 0: replaced = value.replace('-', '.') return replaced[:6] + replaced[8:] if i == 1: replac = value.replace(' ', '').replace('-', '').replace('+', '').replace('(', '').replace(')', '') return replac[1:] if i == 2: replac = value.replace('[at]', '@') return replac def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def sort(table): return sorted(table, key=lambda l: l[2]) def main(table): return sort(transpose(transform(transpose(split_colum(delete_empty_rows(delete_duplicate_rows(delete_empty_colums(table))))))))" "def do_magic(row, i): el = row[i] if el.find('(') != -1: row[i] = f'{el[1:4]} {el[6:9]}-{el[10:12]}{el[13:15]}' else: try: f = float(el) row[i] = '{:.3f}'.format(f) except ValueError: p = el.find('.') row[i] = f'{el[:p - 2]} {el[p + 2:]}' def main(a): def compare_tables(a1, a2): for (i, j) in zip(a1, a2): if i != j: return False return True a = [list(filter(None, row)) for row in a] a = list(filter(None, a)) a = [[a[j][i] for j in range(len(a))] for i in range(len(a[0]))] for row in a: for i in range(len(row)): do_magic(row, i) for i in range(len(a)): for j in range(i + 1, len(a)): if compare_tables(a[i], a[j]): a.pop(j) return a" "def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): for row in table: del row[1] return table def transformer(i, value): if i == 2: replaced = value.split('-') return replaced[2] + '/' + replaced[1] + '/' + replaced[0] if i == 0: digit_str = value[2:] return str(f'{round(float(digit_str), 2):.{2}f}') if i == 1: return value def transform(table): for i in range(len(table)): for j in range(len(table[i]) + 1): if j == 0: if table[i][j][:-6] == 'Y': table[i].insert(1, 'Выполнено') else: table[i].insert(1, 'Не выполнено') table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(delete_duplicate_columns(delete_empty_rows(table)))" "def transpose(table): table.sort(key=lambda i: i[1], reverse=False) response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[2] is not None] def delete_duplicate_columns(table): for row in table: del row[0] del row[0] return table def transformer(i, value): if i == 0: return 'Выполнено' if value == '1' else 'Не выполнено' if i == 1: name = value.split() return f'{name[2]}, {name[0][0]}.{name[1]}' if i == 2: a = str(round(float(value) * 100, 1)) + '%' if a.__contains__('.5%'): return str(int(round(float(value) * 100, 1))) + '%' else: return str(int(round(float(value) * 100, 0))) + '%' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transpose(transform(delete_duplicate_columns(delete_empty_rows(table))))" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst): for i in lst: s = i[0].split(';') i[0] = s[1] i.insert(2, s[0]) return lst def format(lst): for i in lst: i[0] = str(int(float(i[0]) * 100)) + '%' i[1] = i[1].split() i[1] = i[1][2] + ' ' + i[1][0] i[2] = i[2].replace('Да', 'true') i[2] = i[2].replace('Нет', 'false') return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def main(lst): lst = transpose(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = format(lst) lst = transpose(lst) return lst" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data] dct = list(dict.fromkeys(tpls)) data = [list(x) for x in dct] new_table = [] for i in data: split = i[0].split(':') i[0] = '(' + split[1][3:6] + ') ' + split[1][7:] date = datetime.strptime(i[1], '%d-%m-%Y') i[1] = date.strftime('%d-%m-%y') if len(split[0]) == 2: i.append('0.0' + split[0][:1]) elif len(split[0]) == 4: i.append('1.00') else: i.append('0.' + split[0][:2]) row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) new_table.append(row) return new_table" "from typing import List def clear_nones(a: List) -> List: result = [] for i in a: retern_2 = [] for el in i: if el is not None: retern_2.append(el) result.append(retern_2) return result def get_strings_procent(a: List) -> List: result = [] for i in a: i[0] = i[0].replace('%', '') i[0] = int(i[0]) / 100 i[0] = str(i[0]) while len(i[0]) != 5: i[0] = i[0] + '0' result.append(i) return result def get_strings_nums(a: List) -> List: result = [] for i in a: i[1] = i[1].replace('\n', '') i[1] = i[1][0:len(i[1]) - 2] + '-' + i[1][len(i[1]) - 2:len(i[1])] result.append(i) return result def get_strings_data(a: List) -> List: result = [] for i in a: i[2] = i[2].replace('\n', '') i[2] = i[2].replace(' ', '') i[2] = i[2].split('-') i[2] = i[2][2] + '/' + i[2][1] + '/' + i[2][0] result.append(i) return result def get_strings_email(a: List) -> List: result = [] for i in a: i[3] = i[3].split('@')[1] result.append(i) return result def main(a): a = clear_nones(a) a = get_strings_procent(a) a = get_strings_nums(a) a = get_strings_data(a) a = get_strings_email(a) return a" "def main(data): return replace_columns(replace_nums(date_reformat(erase_emails(delete_empty_columns(transponse(delete_empty_columns(transponse(delete_empty_columns(delete_doubles_rows(data)))))))))) def delete_doubles_columns(data): columns_to_delete = [] for st in data: for el1 in range(len(st)): for el2 in range(el1, len(st)): if not el1 == el2: if st[el1] == st[el2]: if el2 not in columns_to_delete: columns_to_delete.append(el2) for j in columns_to_delete: for i in range(len(data)): _ = data[i].pop(j) return data def replace_columns(data_): data = data_ for i in range(len(data)): (data[i][1], data[i][2]) = (data[i][2], data[i][1]) pass return data def replace_nums(data_): data = data_ for i in range(len(data)): for j in range(len(data[i])): if data[i][j] is not None and data[i][j].find('.') != -1: st = data[i][j].split('.') (st[0], st[2]) = (st[2], st[0]) data[i][j] = '-'.join(st) pass pass pass return data def delete_empty_columns(data): columns_to_delete = [] rows = len(data) for el1 in range(len(data[0])): delete = True for str in data: if str[el1] is not None: delete = False break if delete: if el1 not in columns_to_delete: columns_to_delete.append(el1) for j in columns_to_delete: for i in range(rows): _ = data[i].pop(j) return data def delete_doubles_rows(data): rows_to_delete = [] for el1 in range(len(data)): for el2 in range(el1, len(data)): if not el1 == el2: if compare(data[el1], data[el2]): rows_to_delete.append(el2) for i in rows_to_delete: data.pop(i) return data def erase_emails(data_): data = data_ for i in range(len(data)): for j in range(len(data[i])): if data[i][j] is not None and data[i][j].find('@') != -1: data[i][j] = data[i][j][0:data[i][j].find('@')] return data def date_reformat(data_): data = data_ for i in range(len(data)): for j in range(len(data[i])): if data[i][j] is not None and (data[i][j].find('N') != -1 or data[i][j].find('Y') != -1): if data[i][j] == 'N': data[i][j] = 'нет' pass else: data[i][j] = 'да' pass return data def sort(data): data.sort(key=lambda x: x[2]) return data def transponse(data): new_data = [] * len(data[0]) for i in range(len(data[0])): new_data.append([''] * len(data)) for i in range(len(data)): for j in range(len(data[0])): new_data[j][i] = data[i][j] return new_data def compare(data1, data2): eq = True for el in range(len(data1)): if not data1[el] == data2[el]: eq = False break return eq" "inl = [['78%', '2002/05/18:863 278-7689', 'Савва Ручман'], ['82%', '2001/11/25:298 615-3831', 'Сергей Домский'], ['42%', '2001/07/07:422 753-5786', 'Радмир Сотберг']] def transform_number(i): number = int(str(i).replace('%', '')) / 100 return f'{number:.1f}' def delete_empty_rows(table): return [row for row in table if row[0] is not None] def surname(i): ns = i.split() return ns[1] def transform_date(i): year = i[2:4] month = i[5:7] day = i[8:10] return day + '-' + month + '-' + year def transform_phone(i): return '(' + i[:3] + ')' + i[3:10] + '-' + i[10:] def custom_key(i): return i[2] def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def main(table): table = delete_empty_rows(table) for i in table: i[1] = i[1].split(':') date = i[1][0] phone = i[1][1] i.pop(1) i.insert(1, date) i.insert(3, phone) i[0] = transform_number(i[0]) i[1] = transform_date(i[1]) i[2] = surname(i[2]) i[3] = transform_phone(i[3]) table.sort(key=custom_key) table = transpose(table) return table" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_columns(table): for i in range(len(table[0])): isNone = True for j in range(len(table)): if table[j][i] is not None: isNone = False if isNone: table[0][i] = 'del' for i in range(len(table[0]) - 1, -1, -1): if table[0][i] == 'del': for j in range(len(table)): table[j].remove(table[j][i]) return table def delete_duplicate_rows(table): res = [] for i in table: if i not in res: res.append(i) return res def transformer(i, value): if i == 0: return value.split(':')[0].replace('-', '') if i == 1: return 'Выполнено' if value == 'Y' else 'Не выполнено' if i == 2: name = value.split('.') return f'{name[0]}.{name[2]}' if i == 3: return value.split('/')[2] def transform(table): table.append([]) for i in range(len(table[1])): table[-1].append(transformer(3, table[0][i])) for i in range(len(table) - 1): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_empty_columns(delete_duplicate_rows(table))))" "def main(a: list): res = [[], [], [], []] i = 0 while i < len(a): if a[i][0] is None: del a[i] else: cell = a[i][0].split('#') res[0].append(cell[0] + '0') res[1].append(a[i][1].replace('-', '.')) res[2].append(a[i][2].replace('[at]', '@')) res[3].append(cell[1][3:]) i += 1 return res" "import re import copy from datetime import datetime def main(lst): lst_copy = copy.deepcopy(lst) ver_lst = lst for i in range(0, len(lst_copy)): for j in range(len(lst_copy[i])): if j < len(lst_copy[i]) - 1: if lst_copy[i][j] == lst_copy[i][j + 1]: ver_lst[i][j] = 1 new_list = [] for j in range(len(lst_copy[i])): if ver_lst[0][j] == 1: new_list.append(j) for i in range(0, len(new_list)): for j in lst_copy: del j[new_list[i]] lst = lst_copy for i in range(0, len(lst)): lst[i][0] = re.sub('[^0-9]', '', lst[i][0]) lst[i][0] = re.sub('.', '', lst[i][0], count=1) lst[i][1] = lst[i][1].replace('0', 'Нет') lst[i][1] = lst[i][1].replace('1', 'Да') lst[i][2] = re.sub('.', '', lst[i][2], count=2) date = lst[i][2] date_obj = datetime.strptime(date, '%y.%m.%d') date_obj = date_obj.strftime('%d.%m.%y') lst[i][2] = date_obj lst[i][3] = re.sub('@\\S*\\s?', '', lst[i][3]) return lst" "def delete_empty_rows(table): return [row for row in table if row[0] is not None] def split_colum(table): n = [] table = [list(item) for item in table] for i in range(len(table)): table[i][0] = table[i][0].split(';', 1) for j in range(1, 3): table[i][j] = table[i][j].split() table[i][0] += table[i][1] + table[i][2] del table[i][1] del table[i][1] for j in range(len(table[i])): n.append(table[i][j]) (n[i][0], n[i][2]) = (n[i][2], n[i][0]) (n[i][0], n[i][1]) = (n[i][1], n[i][0]) return n def transformer(i, value): if i == 0: replaced = value.replace('-', '') return replaced[7:] if i == 1: return value.partition('[at]')[2] if i == 2: replaced1 = value.partition(' ')[2].partition('.')[0] replaced2 = value.partition(' ')[0] replaced3 = replaced1 + '. ' + replaced2 return replaced3 if i == 3: replaced = value.replace('.', '-') n = list(replaced) buf = n[:2] n[:2] = n[-2:] n[-2:] = buf return ''.join(n) def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def main(table): return transpose(transform(transpose(split_colum(delete_empty_rows(table)))))" "def main(lst): k = [] for i in lst: for p in i[:]: if p is None: i.remove(p) else: continue for i in lst[:]: if len(i) == 0: lst.remove(i) else: continue for i in lst: if i in k: continue else: k.append(i) resultat = [] for podspis in k: da = podspis[0] da = da.replace('Нет', '0') da = da.replace('Да', '1') procent = pr(podspis[1]) god = podspis[2] imya = podspis[2] imya2 = podspis[2] imya = imya[imya.find(' ') + 1:imya.find('.') + 1] imya += ' ' + imya2[:imya2.find(',')] god = god[god.find('#') + 1:god.find('-')] tmp = [] tmp.append(da) tmp.append(procent) tmp.append(god) tmp.append(imya) resultat.append(tmp) resultat = list(map(list, zip(*resultat))) return resultat def pr(proc): if proc[0] == '0' and len(proc) == 2: proc = '0.0' return proc elif len(proc) == 2: proc = '0' + proc proc = round(float('0.' + proc[:2]), 1) proc = str(proc) return proc else: proc = round(float('0.' + proc[:2]), 1) proc = str(proc) return proc" "import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [x for x in data if x[1] is not None] data = [x for x in tpls] new_table = [] row1 = [] row2 = [] row3 = [] row4 = [] for i in data: i.pop(3) split = i[0].split(' ') i[0] = split[1] + ' ' + split[0] i[1] = re.sub('@.*', '', i[1]) if i[2] == 'да': i[2] = 'Y' else: i[2] = 'N' if len(i[3]) == 2: i[3] = '0.0' + i[3][:-1] + '0' elif len(i[3]) == 4: i[3] = '1.000' else: i[3] = '0.' + i[3][:-1] + '0' row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) row4.append(i[3]) new_table.append(row1) new_table.append(row2) new_table.append(row3) new_table.append(row4) return new_table" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0]] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] row1 = [] row2 = [] row3 = [] for i in data: date = datetime.strptime(i[0], '%y/%m/%d') i[0] = date.strftime('%d/%m/%y') split = i[1].split(';') i[1] = str(round(float(split[0]), 1)) if split[1] == 'Y': i.append('Да') else: i.append('Нет') row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) new_table.append(row1) new_table.append(row2) new_table.append(row3) return new_table" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst): for i in lst: s = i[0].split(';') i[0] = s[1] i.insert(2, s[0]) return lst def format(lst): for i in lst: i[0] = i[0].split('!') i[1] = i[1] + '00' k = i[0][1] k = k.split(' ') k = k[1] + ' ' + k[0][:2] i[0] = i[0][0].split('/') i[0] = f'{i[0][2]}-{i[0][1]}-{i[0][0]}' i.append(k) return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = format(lst) return lst" "def double_lines(data): result = [] for i in data: if i not in result: result.append(i) return result def delim(data): result = [] result_row = [] for i in data: result_row.append(i[0].split('!')[0]) result_row.append(i[0].split('!')[1]) result_row.append(i[1]) result.append(result_row) result_row = [] return result def reformat(data): result = [] result_row = [] for i in data: result_row.append(str(round(round(float(i[0]) * 100 + 0.06, 1))) + '%') result_row.append(i[1].replace('-', '.')) result_row.append(i[2].split('@')[0]) result.append(result_row) result_row = [] return result def main(data): data = double_lines(data) data = delim(data) data = reformat(data) return data" "def main(x): new_table = [] for i in x: if i != [None, None, None, None]: new_table.append(i) for i in new_table: i[3] = i[3].replace('-', '/') firstColumSplit = i[0].split('#') i[0] = '{:.3f}'.format(round(float(firstColumSplit[0]), 3)) i[2] = firstColumSplit[1][:13] + firstColumSplit[1][14:] if i[1] == 'Выполнено': i[1] = 'true' else: i[1] = 'false' return new_table" "def first(s): new = [] for i in range(len(s)): cur = [] for j in range(len(s[i])): if s[i][j] is not None: cur.append(s[i][j]) new.append(cur) return new def second(s): for i in s: i[0] = i[0].replace('[at]', '@') if i[1] == 'Выполнено': i[1] = 'true' elif i[1] == 'Не выполнено': i[1] = 'false' i[2] = i[2].split(' ')[2] + ' ' + i[2].split(' ')[0] i[3] = str(round(float(i[3]), 1)) return s def third(s): mails = [] t_f = [] name = [] number = [] for i in s: mails.append(i[0]) t_f.append(i[1]) name.append(i[2]) number.append(i[3]) new = [] new.append(mails) new.append(t_f) new.append(name) new.append(number) return new def main(s): return third(second(first(s)))" "def main(table): parsed = set() (date, surname, result) = ([], [], []) for (data, fullname, _, _) in table: if data in parsed and data is not None: continue parsed.add(data) parsed_data = data.split('&') date.append(parsed_data[0].replace('/', '-')) surname.append(fullname.split()[1]) result.append('true' if parsed_data[1] == 'да' else 'false') return [date, surname, result]" "def main(table): tb = [] b = [] for i in range(len(table)): for j in table[i]: if j not in b: b.append(j) if b[0]: tb.append(b) b = [] tosort = {} for i in range(len(tb)): if tb[i][0] == 'Y': tb[i][0] = '1' elif tb[i][0] == 'N': tb[i][0] = '0' tmp = tb[i][1].split() tb[i][1] = tmp[2] + ' ' + tmp[0][0] + '.' + tmp[1] tb[i][2] = tb[i][2].split('@')[0] tosort[tb[i][1]] = tb[i] tosort = dict(sorted(tosort.items())) tb = list(tosort.values()) result = [] k = 0 for j in range(len(tb[0])): tmp = [] for i in range(len(tb)): tmp.append(tb[i][k]) k += 1 result.append(tmp) return result" "def main(table): parsed = set() result = [] for (date, fullname, _, _, percent, email, _) in table: (pdate, surname, score, domain) = ([], [], [], []) if fullname in parsed and fullname is not None: continue parsed.add(fullname) ppdate = date.split('-') psurname = fullname.split(' ') pdate.append(f'{ppdate[2][-2:]}/{ppdate[1]}/{ppdate[0]}') surname.append(f'{psurname[1]} {psurname[0][0]}.') score.append(str(round(float(percent.strip('%')) / 100.0, 1))) domain.append(email.split('@')[1]) result.append([pdate[0], surname[0], score[0], domain[0]]) return sorted(result, key=lambda x: x[1])" "def main(a: list): i = 0 while i < len(a): if a.count(a[i]) > 1 or a[i][0] is None: del a[i] else: del a[i][4] a[i][0] = a[i][0][4:] a[i][1] = a[i][1][8:] + '-' + a[i][1][5:7] + '-' + a[i][1][:4] name = a[i][2].split(' ') a[i][2] = name[2] + ' ' + name[0] a[i][3] = str(round(float('0.' + a[i][3][:-1]), 1)) i += 1 a.sort(key=lambda name: name[2]) res = [[0 for j in range(len(a))] for i in range(len(a[0]))] for i in range(len(a)): for j in range(len(a[0])): res[j][i] = a[i][j] return res" "def main(table): parsed = set() result = [] for (_, date, data) in table: (pdate, email, num) = ([], [], []) if data in parsed and data is not None: continue parsed.add(data) ppdate = date.split('.') pdata = data.split('#') pdate.append(f'{ppdate[0]}-{ppdate[1]}-{ppdate[2][-2:]}') email.append(pdata[1].replace('@', '[at]')) num.append(f'{pdata[0][3:]}') result.append([pdate[0], email[0], num[0]]) return sorted(result, key=lambda x: x[1])" "import re import datetime as DT def main(table): for i in range(0, len(table)): del table[i][1:3] table1 = [i for i in table if i != [None, None, None, None, None]] table2 = [] for i in table1: if i not in table2: table2.append(i) table3 = [] for i in range(0, len(table2)): d = list(dict.fromkeys(table2[i])) table3.append(d) for i in range(0, len(table3)): table3[i][0] = re.sub('\\@\\w+\\.+\\w+', '', table3[i][0]) table3[i][1] = '({}) {}-{}'.format(table3[i][1][:3], table3[i][1][3:6], table3[i][1][6:]) date = DT.datetime.strptime(table3[i][2], '%d.%m.%y').date() table3[i][2] = date.strftime('%y.%m.%d') name = table3[i][3].split() table3[i][3] = '{} {}.{}'.format(name[2], name[0][0], name[1]) table = [list(x) for x in zip(*table3)] return table" "def main(table): parsed = set() (datedot, phone, state) = ([], [], []) for (date, _, num, _, flag) in table: if date in parsed or date is None: continue parsed.add(date) datedot.append(date.replace('.', '-')) phone.append(f'{num[:2]} {num[2:5]} {num[5:8]}-{num[8:]}') state.append('true' if flag == 'Выполнено' else 'false') result = [] for i in range(0, len(datedot)): result.append([datedot[i], phone[i], state[i]]) return result" "def main(table): parsed = set() (domain, round, datedot) = ([], [], []) for (_, _, mail, num, date) in table: if date in parsed or date is None: continue parsed.add(date) domain.append(mail.split('[at]')[-1]) round.append(f'{num}0') datedot.append(date[2:].replace('.', '-')) result = [] for i in range(0, len(datedot)): result.append([domain[i], round[i], datedot[i]]) return result" "def delete_empty_colums(table): table = zip(*table) table = [x for x in table if any(x)] table = [list(row) for row in zip(*table)] return table def split_colum(table): table = [list(item) for item in table] n = [] for i in range(len(table)): for j in range(len(table[i])): table[i][j] = table[i][j].split(';', 1) for j in range(0, len(table[i]), 2): table[i][j].extend(table[i][j + 1]) del table[i][j + 1] for j in range(len(table[i])): n.append(table[i][j]) (n[i][1], n[i][2]) = (n[i][2], n[i][1]) return n def transformer(i, value): if i == 0: replaced1 = value.partition(' ')[0] replaced2 = value.partition('.')[2] replaced3 = replaced1 + replaced2 return replaced3 if i == 1: return value.partition('[at]')[2] if i == 2: replaced = value.replace('/', '.') n = list(replaced) buf = n[:2] n[:2] = n[-2:] n[-2:] = buf return ''.join(n) def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def sort(table): return sorted(table, key=lambda l: l[0]) def main(table): return sort(transpose(transform(transpose(split_colum(delete_empty_colums(table))))))" "def parse_result(result): (a, b, c, d) = ([], [], [], []) for arr in result: a.append(arr[0]) b.append(arr[1]) c.append(arr[2]) d.append(arr[3]) return [a, b, c, d] def main(table): parsed = set() result = [] for (data, score, res, _) in table: (date, pscore, surname, pres) = ([], [], [], []) if data in parsed or data is None: continue parsed.add(data) pdata = data.split('!') date.append(pdata[0].replace('-', '/')) pscore.append(f'{score}00') surname.append(pdata[1].split()[0]) pres.append('1' if res == 'Y' else '0') result.append([date[0], pscore[0], surname[0], pres[0]]) result = sorted(result, key=lambda x: x[2]) return parse_result(result)" "import re from itertools import groupby import itertools def unique_items(x): found = set() for item in x: if len(item) > 0: if item[0] not in found: yield item found.add(item[0]) def main(x): for i in range(0, len(x)): x[i] = [k for k in x[i] if k] x = list(unique_items(x)) x = [i for i in x if i] transpoted_x = list(map(list, itertools.zip_longest(*x, fillvalue=None))) transpoted_x = [i for (i, _) in groupby(transpoted_x)] transpoted_x = list(map(list, itertools.zip_longest(*transpoted_x, fillvalue=None))) true_x = [] for i in range(0, len(transpoted_x)): massiv = [] nomer = re.split('!', transpoted_x[i][0])[1] nomer_1 = re.findall('\\s\\d{3}\\s', nomer) nomer_1 = re.sub(' ', '', nomer_1[0]) nomer = re.sub('\\s\\d{3}\\s', f' ({nomer_1}) ', nomer) data = re.split('!', transpoted_x[i][0])[0] data_1 = re.findall('\\d{4}', data)[0] data_1 = data_1[2:] data = re.sub('\\d{4}', data_1, data) data = re.split('-', data) data = f'{data[2]}-{data[1]}-{data[0]}' massiv.append(nomer) massiv.append(data) massiv.append(re.sub('\\[at]', '@', transpoted_x[i][1])) true_x.append(massiv) return sorted(true_x, key=lambda row: row[2])" "from operator import itemgetter def first(s): new = [] for i in range(len(s)): cur = [] for j in range(len(s[i])): if s[i][j] not in cur: cur.append(s[i][j]) new.append(cur) return new def second(s): new = [] for i in s: if i not in new: new.append(i) return new def third(s): new = [] for i in s: cur = [] cur.append(i[0]) cur.append(i[1].split(':')[0]) cur.append(i[1].split(':')[1]) new.append(cur) return new def fourth(s): for i in s: i[0] = i[0].split(',')[0] i[1] = i[1][2:5] + '-' + i[1][5:8] + '-' + i[1][8:] i[2] = i[2].split('@')[0] return s def fifth(s): new = sorted(s, key=itemgetter(0)) for i in new: i[0] = i[0] s1 = i[1] s2 = i[2] i[1] = s2 i[2] = s1 return new def main(s): return fifth(fourth(third(second(first(s)))))" "def trans(matrix): trans_mat = [[0 for j in range(len(matrix))] for i in range(len(matrix[0]))] for i in range(len(matrix)): for j in range(len(matrix[0])): trans_mat[j][i] = matrix[i][j] return trans_mat def main(inp): out = [] for row in inp: lst = [] num = float(row[0].split('!')[0]) row[0] = row[0][row[0].index('!') + 1:] row[0] = row[0].split(',')[0] lst.append(f'{num:.{4}f}') row[1] = row[1].split('@')[1] lst.extend(row) if lst not in out: out.append(lst) out = trans(out) k = out[2] out[2] = out[1] out[1] = k return out[:-1]" "def main(table): newTable = [] for i in range(len(table)): for j in range(i + 1, len(table)): if table[i] == table[j]: table[j] = [None, None, None] for i in table: if i != [None, None, None]: row = [] list = i[0].split('[at]') row.append(list[1]) t = i[1].split(':') if t[0] == '0': znach = 'false' else: znach = 'true' row.append(znach) t2 = float(t[1]) row.append(str(round(t2, 1))) newTable.append(row) return newTable" "def main(x): x1 = [] for i in x: if i not in x1 and i != [None, None, None, None, None, None]: x1.append(i) x = x1 for i in range(0, len(x)): x1 = [] for k in range(0, len(x[i])): if x[i][k] is not None and x[i][k] not in x1: x1.append(x[i][k]) x[i] = x1 x[i][0] = x[i][0][x[i][0].find(' ') + 1:] + ' ' + x[i][0][:x[i][0].find(' ')] x[i][1] = preb(x[i][1]) if x[i][2] == '1': x[i][2] = 'да' else: x[i][2] = 'нет' x1 = list(x[i][3].split('.')) x[i][3] = x1[2] + '.' + x1[1] + '.' + x1[0] return x def preb(x): if x == '1.0': return '100%' elif x == '0.0': return '0%' else: return x[x.find('.') + 1:] + '0%'" "def del_row(s): s1 = [] for row in s: if row not in s1: s1.append(row) return s1 def transpose(s): s1 = [] for i in range(len(s[0])): s1.append([]) for j in range(len(s)): s1[i].append(s[j][i]) return s1 def main(s): s = [row for row in s if row[0] is not None] s = del_row(s) s = transpose(s) s = del_row(s) s = transpose(s) for row in s: row[2] = row[2].split(' ')[1] row[1] = str(int(float(row[1]) * 100)) + '%' for row in s: b = row[0].split('&') if b[1] == '1': row[0] = 'Y' else: row[0] = 'N' b[0] = b[0].replace('+7', '') b[0] = b[0][:3] + ' ' + b[0][3:6] + '-' + b[0][6:] row.insert(2, b[0]) return s" "def del_nul(x): for row in x: for elem in row[:]: if elem is None: row.remove(elem) for row in x[:]: if len(row) == 0: x.remove(row) return x def intable0(x, unique): for row in x: if row not in unique: unique.append(row) return x def intable1(x, unique, unique1): for row in unique: lst = [] for elem in row: if elem not in lst: lst.append(elem) unique1.append(lst) return unique1 def main(x): c = [] del_nul(x) unique = [] unique1 = [] intable0(x, unique) intable1(x, unique, unique1) for row in unique1: al = [] y = '' mail = '' phone = '' phone1 = '' numm = '' for i in row[0]: phone += i phone = phone[:phone.index(':')] phone = phone[5:] for i in row[0]: phone1 += i if phone1[13] == 'f': y = '0' else: y = '1' for i in row[1]: numm += i numm = '{:,.1f}'.format(float(numm)) numm = str(numm) for i in row[2]: mail += i mail = mail[mail.index('@') + 1:] al.append(phone) al.append(y) al.append(numm) al.append(mail) c.append(al) return c" "def main(x): new_table = [] for i in x: if i != [None, None, None, None, None]: new_table.append(i) for i in new_table: i[1] = i[1].replace('[at]', '@') secondColumSplit = i[1].split('#') i[1] = secondColumSplit[1] i[2] = i[2].split(',')[0].replace(' ', '') a = '-' + i[4][8:10] + '-' + i[4][10:12] i[4] = i[4][0:2] + ' (' + i[4][2:5] + ') ' + i[4][5:8] + a if secondColumSplit[0] == 'true': i[3] = 'Y' else: i[3] = 'N' li = [] new2_table = [] for i in new_table: if i not in li: li.append(i) for i in li: new2_table.append([x for x in i if x is not None]) new2_table.sort(key=lambda x: x[1]) return new2_table" "def main(a: list): res = [[], [], [], []] for i in reversed(range(len(a))): if a.count(a[i]) > 1 or a[i][0] is None: del a[i] for i in range(len(a)): del a[i][3] res[0].append(a[i][0].replace('/', '.')) res[1].append(a[i][1].split('@')[0]) cell = a[i][2].split(';') res[2].append('(' + cell[1][:3] + ')' + cell[1][3:]) if cell[0] == 'Y': res[3].append('Да') if cell[0] == 'N': res[3].append('Нет') return res" "import re def delete_empty_rows(table): return [row for row in table if row[0] is not None] def d_d_c(table): for i in table: del i[2] return table def d_d_r(table, num): state = 0 for j in range(num, len(table) - 1): state = table[j][3] num += 1 for i in range(num, len(table)): try: if table[i][3] == state: del table[i] except IndexError: return d_d_r(table, j) table = delete_empty_rows(table) return table def transformer(table): pos = '([a-z0-9_]*)\\[at](\\w*.\\w*)' for j in table: str = j[1] mat = re.findall(pos, str) j[1] = mat[0][0] + '@' + mat[0][1] if int(j[0]): j[0] = 'Y' else: j[0] = 'N' j[3] = repr(round(float(j[3]), 1)) return table def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def transformName(table): name = '^([А-Яа-я])*' for i in table: str = i[2] matches1 = re.search(name, str) i[2] = matches1[0] return table def main(table): return transformer(transformName(d_d_r(delete_empty_rows(d_d_c(table)), 0)))" "import math def main(table): dict = [] result = [[], [], []] for row in table: if row[0] is None or row in dict: continue dict.append(row) result[0].append(row[0].split(' ')[1]) thirdColumn = row[2].split('#') result[1].append(thirdColumn[1] + '000') if thirdColumn[0] == 'Y': result[2].append(str(1)) else: result[2].append(str(0)) return result" "import re def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_column(table): table = transpose(table) table = [column for column in table if column[2] is not None] return transpose(table) def delete_duplicate_columns(table): for column in table: del column[3] return table def delete_duplicate_rows(table): table_new = table k = 0 while k < len(table): i = 0 while i < len(table) - 1: j = i + 1 while j < len(table): if table[i][1] == table[j][1]: table = delete_duplicate_rows_sub(table, j) j += 1 i += 1 k += 1 return table def delete_duplicate_rows_sub(table, n): table = transpose(table) for column in table: del column[n] return transpose(table) def transformer(i, value): if i == 0: return str(f'{round(float(value), 1):.{1}f}') if i == 1: replaced = value.split('-') return replaced[2] + '/' + replaced[1] + '/' + replaced[0] if i == 2: return value def transform(table): for i in range(len(table)): for j in range(len(table[i])): if j == 2: mid_table = table[i][j].split(':') p = '\\s*([А-я])\\w*\\s*([А-я ])\\.\\s*([А-я]*)\\s*' matches = re.findall(pattern=p, string=mid_table[0]) mid_table = mid_table[1].split('@') table[i][j] = mid_table[1] table[i].insert(3, str(matches[0][2] + ' ' + matches[0][0] + '.' + matches[0][1] + '.')) table[i][j] = transformer(j, table[i][j]) return table def main(table): return transpose(transform(delete_duplicate_rows(delete_duplicate_columns(delete_empty_column(table)))))" "def main(a: list): for i in reversed(range(len(a))): if a.count(a[i]) > 1 or a[i][0] is None: del a[i] for i in range(len(a)): del a[i][1] del a[i][3] cell = a[i][0].split(' ') a[i][0] = cell[1] a[i][1] = a[i][1].replace('/', '.') if a[i][2] == 'да': a[i][2] = '1' else: a[i][2] = '0' return a" "def main(x): res = [] for i in x: if None in i: continue else: res.append(i) for i in range(len(res)): if res[i][0][:1] == 'Y': res[i].append('Выполнено') elif res[i][0][:1] == 'N': res[i].append('Не выполнено') value = int(res[i][0].split('#')[1].replace('%', '')) res[i][0] = format(value / 100, '.3f') res[i][1] = res[i][1].split('[at]')[0] new_res = [] for i in res[0]: new_res.append(list()) for i in range(len(res[0])): for j in range(0, len(res)): new_res[i].append(res[j][i]) return new_res" "def main(table): new_table = list() for row in table: if row not in new_table: new_table.append(row) table = new_table i = 0 new_table = list() for row in table: if row != [None, None, None]: new_table.append(row) table = new_table for row in table: row[0] = ''.join(row[0].split('-')[::1]) row[1] = str(round(float(row[1]), 2)) row[1] = toFixed(row[1], 2) if row[2].find(' ') != -1: row[2] = row[2][:row[2].find(' ')] + row[2][row[2].find(' ') + 3:] table = list(map(list, zip(*table))) return table def toFixed(f: float, n=0): (a, b) = str(f).split('.') return '{}.{}{}'.format(a, b[:n], '0' * (n - len(b)))" "def first(s): new = [] for i in s: if i not in new: new.append(i) return new def second(s): new = [] for i in s: cur = [] for j in i: if j is not None: cur.append(j) if len(cur) != 0: new.append(cur) return new def third(s): new = [] for i in s: cur = [] cur.append(i[0].split('&')[1] + '0') cur.append(i[0].split('&')[0]) cur.append(i[1]) cur.append(i[2]) new.append(cur) return new def fourth(s): for i in s: i[1] = i[1].split('.')[2] + '/' + i[1].split('.')[1] + '/' + i[1].split('.')[0] i[2] = i[2].replace('[at]', '@') i[3] = i[3][2:7] + ' ' + i[3][7:10] + i[3][10:13] + i[3][14:] return s def main(s): return fourth(third(second(first(s))))" "def main(a: list): i = len(a) - 1 while i >= 0: if a.count(a[i]) > 1: del a[i] else: a[i][0] = a[i][0][8:] + a[i][0][4:7] + '-' + a[i][0][:4] a[i][1] = a[i][1][6:] cell = a[i][2].split('&') a[i][2] = cell[1].replace('@', '[at]') a[i].append('%.3f' % round(float(cell[0]), 3)) i -= 1 return a" "def main(z): result = [] for row in z: if None in row: continue parsed = row[0].split('-') row0 = f'{parsed[2][2:]}-{parsed[1]}-{parsed[0]}' row1 = row[1].replace('+7', '') row2 = f'{int((float(row[-1]) * 100).__round__())}%' result.append([row0, row1, row2]) return result" "def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data] dct = list(dict.fromkeys(tpls)) data = [list(x) for x in dct] new_table = [] for i in data: i[0] = str(round(float(i[0]), 2)) i[3] = i[3].partition('[at]')[0] + '@' + i[3].partition('[at]')[2] if len(i[0]) == 3: i[0] = i[0] + '0' if i[4] == 'Y': i[4] = '1' else: i[4] = '0' row = [i[0], i[3], i[-1]] new_table.append(row) return new_table" "def emptyCols(table): for x in table: del x[2] del x[0] return table def deleteRows(table): i = 0 while i < len(table): j = i + 1 while j < len(table): if table[i][0] == table[j][0]: mark = True for m in range(1, len(table[0])): if table[i][m] != table[j][m]: mark = False break if mark: del table[j] j -= 1 j += 1 i += 1 return table def separate(table): for x in table: x.append(x[1][x[1].find(':') + 1:]) if x[1][0] == 't': x[1] = 'Выполнено' else: x[1] = 'Не выполнено' return table def changeByVariant(table): for x in table: x[0] = x[0][4:10] + '-' + x[0][10:] x[2] = x[2][:x[2].find('@')] + '[at]' + x[2][x[2].find('@') + 1:] return table def main(table): return changeByVariant(separate(deleteRows(emptyCols(table))))" "from operator import itemgetter def first(s): new = [] for i in s: cur = [] for j in i: if j not in cur: cur.append(j) new.append(cur) return new def second(s): new = [] for i in s: cur = [] for j in i: if j is not None: cur.append(j) new.append(cur) return new def third(s): new = [] for i in s: cur = [] cur.append(i[0].split('|')[0]) cur.append(i[0].split('|')[1]) cur.append(i[1]) new.append(cur) return new def fourth(s): for i in s: if len(str(round(float(i[0]), 3)).split('.')[1]) == 1: i[0] = str(round(float(i[0]), 3)) + '00' elif len(str(round(float(i[0]), 3)).split('.')[1]) == 2: i[0] = str(round(float(i[0]), 3)) + '0' else: i[0] = str(round(float(i[0]), 3)) i[1] = i[1].split(',')[0] + i[1].split(',')[1].split('.')[0] + '.' if i[2] == 'Да': i[2] = 'да' elif i[2] == 'Нет': i[2] = 'нет' return s def fifth(s): new = sorted(s, key=itemgetter(1)) return new def sixth(s): new = [] number = [] names = [] y_n = [] for i in range(len(s)): number.append(s[i][0]) names.append(s[i][1]) y_n.append(s[i][2]) new.append(number) new.append(names) new.append(y_n) return new def main(s): return sixth(fifth(fourth(third(second(first(s))))))" "import re def main(arr): bl = [*map(lambda x: 'true' if x[0] == '1' else 'false', arr)] res = ['-'.join(arr[i][1].split('-')[::-1]) for i in range(len(arr))] mail = [re.search('\\w+\\.\\w+', arr[i][3])[0] for i in range(len(arr))] word = [i[2] + ' ' + i[0][0] + '.' + i[1] for i in [arr[i][4].split() for i in range(len(arr))]] return [bl, res, mail, word]" "def main(table): tmp_tb = [] for y in table: if y[0] is not None: t = [] for x in y: if x is not None: t.append(x) t.append(None) tmp_tb.append(t) for i in range(len(tmp_tb)): if tmp_tb[i][0] == '0': tmp_tb[i][0] = 'Не выполнено' else: tmp_tb[i][0] = 'Выполнено' tmp_tb[i][1] = tmp_tb[i][1].replace('/', '-') date = tmp_tb[i][1][8:] + tmp_tb[i][1][4:7] + '-' + tmp_tb[i][1][2:4] tmp_tb[i][1] = date tmp_tb[i][2] = tmp_tb[i][2].replace('&', ' ') tmp_tb[i][2] = tmp_tb[i][2].replace('@', ' ') string = tmp_tb[i][2].split(' ') date = string[2] tmp_tb[i][2] = date date = string[1] tmp_tb[i][3] = date n = [] for i in tmp_tb: if i not in n: n.append(i) return n" "def main(_list): for line in _list: line[0] = line[0].split('&') line[1] = line[0][0] line[0] = line[0][1] (line[1], line[2]) = (line[2], line[1]) line[0] = line[0][line[0].find(']') + 1:] line[2] = line[2].replace('-', '/') line[2] = line[2][:6] + line[2][8:] line[1] = line[1] + '00' return _list" "def column_1(s): s = ' '.join(s.split(' ')[::-1]) return s def column_2(ss): i = ss.find('.') s = ss[i - 1:] + '00' return s def column_3(sss): if sss[0] == 'д': return 'Y' elif sss[0] == 'н': return 'N' def column_4(ssss): s = f'{ssss[8:]}/{ssss[3:5]}/{ssss[:2]}' return s def custom_key(lstlst): return lstlst[0] def main(lst): lstlst = [] k = 0 for i in range(len(lst)): if all((j is None for j in lst[i])) is True: continue lstlst.append([]) for j in range(len(lst[i])): if j == 1: lstlst[k].append(column_1(lst[i][j])) elif j == 4: lstlst[k].append(column_2(lst[i][j])) lstlst[k].append(column_3(lst[i][j])) elif j == 5: lstlst[k].append(column_4(lst[i][j])) k += 1 lstlst.sort(key=custom_key) return lstlst" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0]] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] sort_table = [] row1 = [] row2 = [] row3 = [] row4 = [] for i in data: i.pop(2) i[0] = i[0].replace('(', ' ').replace(')', ' ') i[1] = str(round(float(i[1]), 2)) + '%' if i[1][0:3] == '0.0': i[1] = i[1].replace('0.0', '') elif len(i[1]) == 4: i[1] = i[1].replace('0.', '') i[1] = i[1][0] + '0' + i[1][1:] else: i[1] = i[1].replace('0.', '') split = i[2].split(' ') i[2] = split[1] date = datetime.strptime(i[3], '%d-%m-%y') i[3] = date.strftime('%y.%m.%d') row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) row.append(i[3]) sort_table.append(row) sort_table.sort() for i in sort_table: row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) row4.append(i[3]) new_table.append(row1) new_table.append(row2) new_table.append(row3) new_table.append(row4) return new_table" "import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0]] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(-1) i[0] = i[0].replace('(', '').replace(')', '')[2:] i[0] = i[0][0:3] + '-' + i[0][3:6] + i[0][6:9] + i[0][10:] i[1] = re.sub('@.*', '', i[1]) if i[2] == 'Да': i[2] = 'Выполнено' else: i[2] = 'Не выполнено' i[3] = str(round(float(i[3]), 2)) + '%' if i[3][0:3] == '0.0': i[3] = i[3].replace('0.0', '') elif len(i[3]) == 4: i[3] = i[3].replace('0.', '') i[3] = i[3][0] + '0' + i[3][1:] else: i[3] = i[3].replace('0.', '') row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) row.append(i[3]) new_table.append(row) new_table.sort() return new_table" "def main(a): def compare_tables(a1, a2): for (e1, e2) in zip(a1, a2): if e1 != e2: return False return True a = [list(filter(None, row)) for row in a] a = list(filter(None, a)) for row in a: (t, row[1]) = row[1].split(':') row.insert(2, t) row[0] = f'{int(row[0][:-1]) / 100:.2f}' row[1] = row[1].replace('[at]', '@') row[2] = row[2].replace('+7', '') row[3] = row[3].replace('да', 'true') row[3] = row[3].replace('нет', 'false') for i in range(len(a)): j = i + 1 while j < len(a): if compare_tables(a[i], a[j]): a.pop(j) else: j += 1 a.sort(key=lambda x: x[1]) return a" "def main(matr): without_repetitions = [] for el in matr: if el not in without_repetitions: without_repetitions.append(el) for i in range(len(without_repetitions)): without_repetitions[i][4] = None without_repetitions[i] = list(filter(None, without_repetitions[i])) matr2 = list(filter(None, without_repetitions)) (new, new2, new3, it, mt) = ([], [], [], [], []) for i in range(0, len(matr2)): name = matr2[i][0].split('.') name[2] = name[2][1:] new2.append(name[2] + ' ' + name[0] + '.') for v in range(0, len(matr2)): matr2[v][0] = new2[v] matr2[v][2] = float(matr2[v][2]) matr2[v][2] = str(round(matr2[v][2], 3)) s = matr2[v][2] matr2[v][2] = s.ljust(len(s[:s.index('.')]) + 4, '0') if matr2[v][3] == '1': matr2[v][3] = 'Y' else: matr2[v][3] = 'N' matr2[v][1] = matr2[v][1].split('/')[2] rt = list(map(list, zip(*matr2))) return rt" "import re def custom_key(people): return people[5] def main(t): for s in t: for i in range(t.count(s) - 1): t.remove(s) t.sort(key=custom_key) nt = [[s[i] for s in t] for i in range(len(t[0]))] for s in nt: for i in range(nt.count(s) - 1): nt.remove(s) if s.count(None) == len(s): nt.remove(s) for i in range(len(nt[0])): nt[0][i] = re.search('\\w+\\.\\w+', nt[0][i]).group() nt[1][i] = nt[1][i][:2] + ' ' + nt[1][i][2:5] + ' ' + nt[1][i][5:8] + '-' + nt[1][i][8:] nt[2][i] = str(int(float(nt[2][i]) * 100)) + '%' nt[3][i] = re.search('(\\w+),', nt[3][i]).group(1) return nt" "def main(x): for i in range(len(x)): for j in x[i]: if j is None: x[i].remove(j) for i in x: for j in i: k = 0 match j: case None: k += 1 match k: case 3: i.remove(j) for i in x: if i[0][:i[0].find('!')] == 'нет': i.append('false') else: i.append('true') i[0] = i[0][i[0].find('!') + 1:] i[1] = i[1][i[1].find('@') + 1:] u = i[0].split('.') i[0] = u[2] + '/' + u[1] + '/' + u[0] x = [list(i) for i in zip(*x)] return x" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [column for column in table if column[0] is not None] def delete_duplicate_rows(table): n = len(table) for i in range(len(table)): if i > len(table) - 1: break cur_d = table[i][0] for j in range(i + 1, len(table)): if j <= len(table) - 1 and cur_d == table[j][0]: del table[j] return table def transformer(i, value): if i == 0: replaced = value[:value.find('@')] return replaced if i == 1: if value == 'Да': return 'Y' elif value == 'Нет': return 'N' if i == 2: return value[4:] if i == 3: return str(round(float(value), 1)) def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(delete_empty_rows(transpose(delete_duplicate_rows(table))))" "def change_list(any_list): s = any_list[0] any_list[0] = any_list[0][:any_list[0].index('-') + 3] any_list[0] += '-' + s[s.index('-') + 3:] any_list[1] = any_list[1].replace('.', '-') any_list[2] = any_list[2].replace('%', '0') any_list[2] = str(any_list[2]).rjust(4, '0') any_list[2] = str(any_list[2])[0] + '.' + str(any_list[2])[1:] any_list[3] = any_list[3][:any_list[3].index(' ')] return any_list def main(old_list): li = [] for el in old_list: if el not in li: li.append(el) li = list(filter(None, li)) for i in range(len(li)): li[i] = change_list(li[i]) return li" "def main(x): for i in x: if i[0] == 'N': i[0] = 'Не выполнено' if i[0] == 'Y': i[0] = 'Выполнено' date = i[1][i[1].find('&') + 1:] fio = i[1][:i[1].find('&')] i[2] = i[2][:i[2].find('[')] tmp = i[2] i[1] = fio i[2] = date i.append(tmp) i[1] = i[1].replace('-', '/') i[2] = i[2][:6] + i[2][7:] return x" "def f(lul): n = [] for i in lul: if i not in n and None not in i: n.append(i) return n def trans(matrix): trans_matrix = [[0 for j in range(len(matrix))] for i in range(len(matrix[0]))] for i in range(len(matrix)): for j in range(len(matrix[0])): trans_matrix[j][i] = matrix[i][j] return trans_matrix def main(matrix): matrix = f(matrix) trans_matrix = trans(matrix) trans_matrix = f(trans_matrix) matrix = trans(trans_matrix) for i in range(len(matrix)): if 'false' in matrix[i][0]: matrix[i][0] = 'Нет' elif 'true' in matrix[i][0]: matrix[i][0] = 'Да' matrix[i][1] = matrix[i][1].replace('(', '') matrix[i][1] = matrix[i][1].replace(')', '') matrix[i][1] = matrix[i][1].replace(' ', '-') splitted = matrix[i][1].split('&') splitted[0] = splitted[0][:10] + splitted[0][11:] splitted[1] = str(float(splitted[1].strip('%')) / 100) while len(splitted[1]) != 6: splitted[1] += '0' matrix[i][1] = splitted[0] matrix[i].insert(2, splitted[1]) matrix[i][3] = matrix[i][3][6:] + '/' + matrix[i][3][3:5] + '/' + matrix[i][3][0:2] return matrix" "def main(a: list): i = 0 while i < len(a): if a[i][0] is None: del a[i] else: cell = a[i][0].split(';') a[i][0] = cell[0][5:8] + '-' + cell[0][8:10] + '-' + cell[0][10:12] a[i][1] = a[i][1][a[i][1].find(']') + 1:] a[i][2] = a[i][2][2:4] + '-' + a[i][2][5:7] + '-' + a[i][2][-2:] temp = '0.' if len(cell[1]) == 3 else '0.0' a[i].append(str(round(float(temp + cell[1][:-1]), 1))) i += 1 a.sort(key=lambda number: number[0]) res = [[], [], [], []] for i in range(4): for j in range(len(a)): res[i].append(a[j][i]) return res" "def main(x): x.remove([None, None, None]) for i in x: if i[2] == 'N': i[2] = 'нет' if i[2] == 'Y': i[2] = 'да' tel = i[0][i[0].find('|') + 1:] date = i[0][:i[0].find('|')] num = '{:.0%}'.format(float(i[1])) yes = i[2] i[0] = tel i[1] = date i[2] = num i.append(yes) i[0] = i[0][:13] + i[0][14:] i[1] = i[1][6:] + i[1][2:6] + i[1][:2] return x" "def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): for row in table: del row[1] return table def transformer(i, value): if i == 0: replaced = value.replace('нет', 'false').replace('да', 'true') return replaced if i == 1: digit = float(value) return f'{digit:.3f}' if i == 2: replaced = value.replace('[at]', '@') return replaced def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(delete_duplicate_columns(delete_empty_rows(table)))" "def trans(m: list): trans_m = [[m[j][i] for j in range(len(m))] for i in range(len(m[0]))] return trans_m def dubl(m): temp = [] for el in m: if el not in temp: temp.append(el) return temp def preob_ans(m): new_m = [] for i in m: new_m.append(i.lower()) return new_m def preob_mail(m): new_m = [] for i in m: new_m.append(i.replace('[at]', '@')) return new_m def preob_num(m): new_m = [] for i in m: s = i[3:] s = s.replace('-', '') s = s.replace(' ', '') new_m.append(s) return new_m def main(old): m = trans(old) trans_m = dubl(m) trans_m[0] = preob_ans(trans_m[0]) trans_m[1] = preob_mail(trans_m[1]) trans_m[2] = preob_num(trans_m[2]) return trans_m" "def check(comp1, comp2): for i in range(0, len(comp2)): if comp1 == comp2[i]: return True return False def main(s): mys = [] chs = [] z = 0 for row in s: cont = [] for elem in row: stri = str(elem) stri = stri.replace('+7', '') stri = stri.replace('(', '') stri = stri.replace(')', '') stri = stri.replace('-', '') if stri.find('@') == -1: if float(stri) < 100: stri = '%.2f' % float(stri) stri = stri.replace('@', '[at]') elem = stri if not check(elem, cont): cont.append(elem) if not check(cont, chs): chs.append(cont) z += 1 for i in range(0, len(chs[0])): mys.append([]) for j in range(0, len(chs)): if i == j: mys[i].append(chs[i][j]) else: mys[i].append(chs[j][i]) return mys" "def main(a): res = list() res1 = list() res2 = list() res3 = list() res4 = list() for i in a: if i[0] is None: continue index = i[0].find('%') tmp_s = i[0][:index] res1.append(f'{round(float(tmp_s), 2) / 100:.1f}') if i[1] is None: continue p = i[1].split('-') tmp_s = p[2] + '.' + p[1] + '.' + p[0] res2.append(tmp_s) if i[2] is None: continue if i[2] == 'да': tmp_s = 'true' elif i[2] == 'нет': tmp_s = 'false' res3.append(tmp_s) if i[4] is None: continue p = i[4].split(' ') tmp_s = p[1] + ' ' + p[0] res4.append(tmp_s) res.append(res1) res.append(res2) res.append(res3) res.append(res4) return res" "def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data] dct = list(dict.fromkeys(tpls)) data = [list(x) for x in dct] new_table = [] for i in data: i[0] = i[0].partition(' ')[0] + ' ' + i[0].partition('. ')[2] i[1] = i[1].partition(' ')[2] fir = i[1].partition('-')[2] i[1] = i[1].partition('-')[0] + '-' + fir.partition('-')[0] i[1] = i[1] + fir.partition('-')[2] i[2] = str(round(float(i[2]), 2)) if len(i[2]) == 3: i[2] = i[2] + '0' i[2] = i[2].replace('.', '') i[2] = i[2].lstrip('0') if len(i[2]) == 0: i[2] = '0' i[2] = i[2] + '%' i[3] = i[3].partition('@')[0] row = [i[0], i[1], i[2], i[3]] new_table.append(row) array = [[new_table[j][i] for j in range(len(new_table))] for i in range(len(new_table[0]))] return array" "def DeleteDuplicates(table): s = set() i = 0 while table[0][i] not in s: s.add(table[0][i]) i += 1 for line in table: line.pop(i) return table def Split(table): for line in table: s = line[0][2:] if line[0][0] == '0': line[0] = 'false' else: line[0] = 'true' line.insert(2, '{0:.3f}'.format(float(s))) return table def PhoneNumber(table): for line in table: s = line[1] line[1] = s[4:7] + s[9:12] + s[13:15] + s[16:18] line[3] = line[3].replace('@', '[at]') return table def GetThirdElement(table): return table[3] def main(table): table = DeleteDuplicates(table) table = Split(table) table = PhoneNumber(table) table = sorted(table, key=GetThirdElement) return table" "def del_dubl_col(table): a = [] b = [] for str in table: for col in str: if col not in b: b.append(col) a.append(b) b = [] return a def del_dubl_str(table): a = [] for str in table: if str not in a: a.append(str) return a def del_empty(table): temp = [] temp_row = [] for i in table: for j in i: if j is not None: temp_row.append(j) temp.append(temp_row) temp_row = [] return temp def divide(table): temp = [] * len(table) for i in range(len(table)): temp.append([''] * (len(table[0]) + 1)) for i in range(len(temp)): for j in range(len(temp[0])): if j == 0: temp[i][j] = table[i][j] return help(temp, table) def help(temp, table): for i in range(len(table)): for j in range(len(table[i])): if table[i][j] is not None and ';' in table[i][j]: t = table[i][j].rfind(';') temp[i][j] = table[i][j][table[i][j].find(';') - 3:t] + '00' for i in range(len(table)): for j in range(1, len(table[0])): temp[i][j + 1] = table[i][j] temp[i][j + 1] = table[i][j][table[i][j].rfind(';') + 1:] return temp def emails(table): temp = table for i in range(len(temp)): for j in range(len(temp[i])): if temp[i][j] is not None and temp[i][j].find('[at]') != -1: temp[i][j] = table[i][j].replace('[at]', '@') return temp def date_reform(table): temp = table for i in range(len(temp)): for j in range(len(temp[i])): if temp is not None and temp[i][j].find('/') != -1: temp[i][j] = table[i][j][-2:] + '-' + table[i][j][table[i][j].find('/') + 1:table[i][j].rfind('/')] + '-' + table[i][j][2:table[i][j].find('/')] return temp def transp(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def word_change(table): temp = table for i in range(len(temp)): temp[i][2] = temp[i][2][temp[i][2].find('.') + 2:] + ' ' + temp[i][2][:temp[i][2].find('.') - 2] return temp def swapper(table): temp_ = [] temp = table temp_ = table[3] temp[3] = table[2] temp[2] = temp_ return temp def main(table): return swapper(transp(word_change(date_reform(divide(emails(del_dubl_str(del_dubl_col(del_empty(table)))))))))" "def change_row(row): row[2] = row[3] row.pop() digit = row[0] digit = float(digit) digit = round(digit, 3) digit = str(digit) row[0] = digit + '0' * (5 - len(digit)) number = row[1] if number[-3] != '-': number = number.split('-', 1) number[1] = number[1][:2] + '-' + number[2:] number = '-'.join(number) else: number = number.split('-', 1) number[1] = number[1].replace('-', '') number = '-'.join(number) row[1] = number row[2] = row[2].replace('@', '[at]') return row def main(table): new = [] for row in table: if not any(row): continue new.append(change_row(row)) new.sort(key=lambda x: x[2]) return new" "def change_row(row): row.pop() name = row[0] name = name.split('#') NY = 'N' if name[0] == '0' else 'Y' fio = name[1] fio = fio.split(' ') fio[0] = fio[0][0] + '.' fio = fio[2] + ', ' + fio[0] + fio[1] number = row[1] number = number.split(' ')[1] number = number[:-2] + '-' + number[-2:] new_row = [NY, fio, number] return new_row def main(table): new = [] for row in table: new.append(change_row(row)) return new" "def transpose(table): transposed = [] for i in range(len(table[0])): transposed.append([]) for j in range(len(table)): transposed[i].append(table[j][i]) return transposed def transform(table): for i in range(len(table)): if table[i][1] == 'да': table[i][1] = 'Да' else: table[i][1] = 'Нет' table[i][3] = format(float(table[i][3]), '.2f') table[i][0] = table[i][0].replace('-', ' ', 1) return table def main(table): result = [] for x in table: if x not in result: result.append(x) result = transpose(transform(result)) del result[2] return result" "def main(nbook): n2 = [] for i in range(len(nbook)): stroka = [] c = 0 for j in range(len(nbook[i])): if nbook[i][j] is not None: stroka.append(nbook[i][j]) c += 1 if c != 0: n2.append(stroka) n1 = [] for i in range(0, len(n2)): if n2[i][0] == 'да': n2[i][0] = 'Да' else: n2[i][0] = 'Нет' podstroka = [] stroka = n2[i][1] stroka = stroka.split('#') podstroka.append(n2[i][0]) podstroka.append(stroka[0]) podstroka.append(stroka[1]) a = '' a += str(podstroka[1][0]) + str(podstroka[1][1]) + str(podstroka[1][2]) + str(podstroka[1][3]) + str(podstroka[1][4]) + str(podstroka[1][5]) + str(podstroka[1][8]) + str(podstroka[1][9]) podstroka[1] = a podstroka[2] = podstroka[2].split('[at]') podstroka[2].pop(0) podstroka[2] = podstroka[2][0] n1.append(podstroka) return n1" "def main(in_table): def transpose(arr): return [[row[i] for row in arr] for i in range(len(arr[0]))] def remove_dublicate_rows(arr): res = [] for row in arr: if row not in res: res.append(row) return res def remove_dublicate_columns(arr): t_arr = transpose(arr) t_arr = remove_dublicate_rows(t_arr) t_arr = transpose(t_arr) return t_arr def remove_blank_columns(arr): t_arr = transpose(arr) res = [] for col in t_arr: if not all((el is None for el in col)): res.append(col) return transpose(res) def split_column_by_hash(arr): t_arr = transpose(arr) fir_row = [] sec_row = [] col_index = -1 for (index, row) in enumerate(t_arr): for el in row: if '#' not in el: break else: fir_row.append(el.split('#')[0]) sec_row.append(el.split('#')[1]) col_index = index res = [] for (index, row) in enumerate(t_arr): if index == col_index: res.append(fir_row) res.append(sec_row) else: res.append(row) return transpose(res) def remove_email_name(arr): for (index, el) in enumerate(arr): arr[index] = el.split('@')[1] def short_name(arr): for (index, el) in enumerate(arr): words = el.split(' ') arr[index] = f'{words[2]}, {words[0][0]}.{words[1]}' def format_phone(arr): for (index, el) in enumerate(arr): arr[index] = el.split(') ')[1].replace('-', '') def format_decimal(arr): for (index, el) in enumerate(arr): (whole_part, decimal_part) = el.split('.') decimal_part = decimal_part + '0' * (len(decimal_part) <= 3) arr[index] = whole_part + '.' + decimal_part new_arr = remove_dublicate_columns(in_table) new_arr = remove_blank_columns(new_arr) new_arr = remove_dublicate_rows(new_arr) new_arr = split_column_by_hash(new_arr) new_arr = transpose(new_arr) remove_email_name(new_arr[2]) short_name(new_arr[0]) format_phone(new_arr[3]) format_decimal(new_arr[1]) res_arr = transpose([new_arr[1], new_arr[2], new_arr[0], new_arr[3]]) return res_arr" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def transformer(i, value): if i == 0: replaced = value.replace('нет', 'N').replace('да', 'Y') return replaced[0:] if i == 1: email = value.split('@') return f'{email[0]}' if i == 2: name = value.split() return f'{name[1]}' if i == 3: call = value.split(' ') call1 = '(' + call[1] + ')' return value.replace(call[1], call1) def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(delete_empty_rows(transpose(delete_empty_rows(table))))" "def main(a: list): i = len(a) - 1 while i >= 0: if a.count(a[i]) > 1: del a[i] else: del a[i][0] a[i][0] = str(int(float(a[i][0]) * 100)) + '%' cell = a[i][1].split('#') a[i][1] = cell[0][6:] + '-' + cell[0][3:5] + '-' + cell[0][:2] a[i].append(cell[1].replace('@', '[at]')) i -= 1 return a" "def main(a: list): res = [[], [], [], []] i = 0 while i < len(a): for j in reversed(range(len(a[i]))): if a[i].count(a[i][j]) > 1 or a[i][j] is None: del a[i][j] if len(a[i]) == 0: del a[i] else: cell = a[i][1].split(';') a[i][0] = a[i][0].replace('(', '').replace(')', '') res[0].append(a[i][0][:10] + a[i][0][11:]) if cell[1] == '1': res[1].append('Да') else: res[1].append('Нет') res[2].append(cell[0][:6] + cell[0][8:]) res[3].append(a[i][2][5:]) i += 1 return res" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst): for i in lst: s = i[0].split(';') i[0] = s[1] i.insert(2, s[0]) return lst def format(lst): for i in lst: i[0] = i[0].split('|') k = i[0][0] j = i[0][1] i[1] = i[1].replace('Да', 'true') i[1] = i[1].replace('Нет', 'false') k = k.split('/') i[0] = f'{k[2]}.{k[1]}.{k[0]}' j = j.split() i.append(f'{j[0]} {j[2]}') return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def main(lst): lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = format(lst) lst = transpose(lst) return lst" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_rows(table): added = set() new_arr = [] for i in table: if i[1] not in added: new_arr.append(i) added.add(i[1]) return new_arr def transformer(i, value): if i == 0: return 'Выполнено' if value == '1' else 'Не выполнено' if i == 3: replaced = value.replace('+7', '') return replaced[0:5] + ' ' + replaced[5:] def transform(table): for i in range(len(table)): for j in range(len(table[i])): if i == 2: continue if i == 1: nt = table[i][j].split('&') table[i][j] = nt[1].replace('@', '[at]') table[i + 1][j] = '%.4f' % float(nt[0]) else: table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_duplicate_rows(delete_empty_rows(table))))" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst): for i in lst: s = i[0].split(';') i[0] = s[1] i.insert(2, s[0]) return lst def format(lst): for i in lst: i[0] = i[0].split('#') k = i[0][0] j = i[0][1] j = j.replace('%', '') j = int(j) / 100 k = k.replace('true', 'Выполнено') k = k.replace('false', 'Не выполнено') i[0] = k lop = i[1].split('/') i[1] = f'{lop[2]}/{lop[1]}/{lop[0]}' i.insert(1, '{0:.3f}'.format(j)) return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def main(lst): lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = format(lst) return lst" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst): for i in lst: s = i[0].split(';') i[0] = s[1] i.insert(2, s[0]) return lst def format(lst): for i in lst: i[1] = i[1].split('|') k = i[1][0] j = i[1][1] i[0] = i[0].split() i[0] = i[0][1] + ' ' + i[0][0] k = k.replace(' ', '') k = k.replace('-', '') i[1] = k i.append(j + '00') return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def main(lst): lst = duble_delete(lst) lst = transpose(lst) lst = duble_delete(lst) lst = transpose(lst) lst = format(lst) lst = transpose(lst) return lst" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst): for i in lst: s = i[0].split(';') i[0] = s[1] i.insert(2, s[0]) return lst def format(lst): for i in lst: i[0] = i[0].replace('%', '') i[0] = '{0:.4f}'.format(int(i[0]) / 100) i[1] = i[1].split() i[1] = i[1][0][:2] + ' ' + i[1][1] i[2] = i[2].split('#') k = i[2][0] h = i[2][1] h = h.replace('@', '[at]') i[2] = k i[2] = i[2].replace('1', 'Выполнено') i[2] = i[2].replace('0', 'Не выполнено') i.append(h) return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def main(lst): lst = duble_delete(lst) lst = format(lst) return lst" "def main(data): return reformat_data(sort(vot(erase_name(erase_nam(erase_emails(delete_doubles_columns(delete_empty_columns(data)))))))) def delete_doubles_columns(data): columns_to_delete = [] for str in data: for el1 in range(len(str)): for el2 in range(el1, len(str)): if not el1 == el2: if str[el1] == str[el2]: if el2 not in columns_to_delete: columns_to_delete.append(el2) for j in columns_to_delete: for i in range(len(data)): s = data[i].pop(j) return data def delete_empty_columns(data): output_data = [row for row in data if row[0] is not None] return output_data def erase_emails(data): for i in range(len(data)): for j in range(len(data[i])): if '[at]' in data[i][j]: stre = data[i][j].partition('[at]')[0] data[i][j] = stre return data def erase_nam(data): for i in range(len(data)): for j in range(len(data[i])): if '+7' in data[i][j]: str = data[i][j].replace('+7', '') data[i][j] = str return data def erase_name(data): for i in range(len(data)): for j in range(len(data[i])): if data[i][j].find(' ') != -1 and '(' not in data[i][j]: str1 = data[i][j].partition(' ')[2] str2 = data[i][j].partition('.')[0] data[i][j] = str1 + ' ' + str2 + '.' return data def vot(data): for i in range(len(data)): for j in range(len(data[i])): if data[i][j] == 'Да': data[i][j] = 'Выполнено' elif data[i][j] == 'Нет': data[i][j] = 'Не выполнено' return data def reformat_data(data): for i in range(len(data)): str1 = data[i][2][0] + data[i][2][1] + data[i][2][2] + data[i][2][3] str2 = data[i][2][5] + data[i][2][6] str3 = data[i][2][8] + data[i][2][9] data[i][2] = str3 + '-' + str2 + '-' + str1 return data def sort(data): data.sort(key=lambda x: x[2][-2:]) return data" "import re def main(lst): for i in range(len(lst)): if lst[i][0] is not None: lst[i][0] = lst[i][0].replace('(', ' ') lst[i][0] = lst[i][0].replace(')', ' ') if lst[i][1] is not None: q101(i, str, lst) lst[i][1] = str(re.findall('.*\\w\\|', lst[i][1])) lst[i][1] = str(lst[i][1]).replace('|', '').replace('[', '') lst[i][1] = str(lst[i][1]).replace(']', '').replace(""'"", '') lst[i][1] = str(lst[i][1]).replace('.', '-') if lst[i][2] is not None: lst[i][2] = re.findall('.*\\w*\\[', lst[i][2]) lst[i][2] = str(lst[i][2]).replace('[', '').replace(']', '') lst[i][2] = str(lst[i][2]).replace(""'"", '') new_lst = [] for i in range(len(lst)): lst[i] = [i for i in lst[i] if i is not None] for i in range(len(lst)): if len(lst[i]): new_lst.append(lst[i]) return new_lst def q101(i, str, lst): if str(re.findall('\\|.*\\w', lst[i][1])) == ""['|Выполнено']"": lst[i].append('да') else: lst[i].append('нет')" "def delete_doubles_columns(data): b = [] c = [] for i in range(len(data[0])): if data[0][i] not in b: b.append(data[0][i]) c.append(i) a = [[data[j][i] for i in c] for j in range(len(data))] return a def delete_doubles_rows(data): a = [] for i in data: if i not in a: a.append(i) return a def delete_empty_rows(data): output_data = [row for row in data if row[0] is not None] return output_data def sort(data): data.sort(key=lambda x: x[0]) return data def transponse(data): new_data = [] * len(data[0]) for i in range(len(data[0])): new_data.append([''] * len(data)) for i in range(len(data)): for j in range(len(data[0])): new_data[j][i] = data[i][j] return new_data def changeTable(data): a = [[i[0][:-3] + i[0][-2:], i[1][:-2], '{}/{}/{}'.format(i[2][-2:], i[2][-5:-3], i[2][:2])] for i in data] return a def main(table): return transponse(changeTable(sort(delete_doubles_rows(delete_doubles_columns(delete_empty_rows(table))))))" "import re def main(table): tmp_tb = [] for y in table: if y[0] is not None: t = [] for x in y: if x is not None: t.append(x) tmp_tb.append(t) for i in range(len(tmp_tb)): string = tmp_tb[i][1].split('!') num = float(string[0]) num = round(round(num, 2) * 100) num = str(num) + '%' string[0] = num string[1] = re.sub('@[a-z.]*', '', string[1]) tmp_tb[i].append(string[0]) tmp_tb[i][1] = tmp_tb[i][1].replace(tmp_tb[i][1], string[1]) tmp_tb[i][0] = tmp_tb[i][0].replace('+7(', '') tmp_tb[i][0] = tmp_tb[i][0].replace(')', ' ') pattern = re.match('([0-9 ]{7}\\-)([0-9]{2})\\-([0-9]{2})', tmp_tb[i][0]) tmp_tb[i][0] = pattern.group(1) + pattern.group(2) + pattern.group(3) n = [] for i in tmp_tb: if i not in n: n.append(i) n.sort(key=lambda row: row[1]) new_lst = list(map(list, zip(*n))) return new_lst" "def main(x): for i in range(0, len(x)): x1 = [] for k in x[i]: if k not in x1: x1.append(k) x[i] = x1 x1 = [] for i in x: if i not in x1: x1.append(i) x = x1 for i in range(0, len(x)): x[i][0] = x[i][0][:x[i][0].find('[at]')] x[i][2] = x[i][1][x[i][1].find('.') + 2:] if x[i][1][:x[i][1].find('!')] == 'да': x[i][1] = 'true' else: x[i][1] = 'false' x1 = x[i][3].split('.')[::-1] date = '' for j in range(0, len(x1)): date += x1[j] if j < len(x1) - 1: date += '/' x[i][3] = date x.sort(key=custom_key) return x def custom_key(x): return x[0]" "from collections import OrderedDict from itertools import groupby def remove_duplicated_rows(lst): return list(OrderedDict(((tuple(x), x) for x in lst)).values()) def remove_empty_columns(lst): data = zip(*lst) data = [x for x in data if any(x)] return list(map(list, zip(*data))) def transpose(lst): return list(map(list, zip(*lst))) def remove_duplicated_columns(lst): data = zip(*lst) data = [x for x in data if not all_equal(x)] return list(map(list, zip(*data))) def all_equal(iterable): g = groupby(iterable) return next(g, True) and (not next(g, False)) def remove_empty_rows(lst): for ls in lst: if all_equal(ls) and ls[0] is None: lst.remove(ls) return lst def split_column_one_and_transform(lst): for ls in lst: src = ls[0].split(';') ls[0] = 'да' if src[1] == 'Выполнено' else 'нет' ls[2] = '{:.4f}'.format(float(src[0])) ls[1] = ls[1].split('@')[1] ls[3] = ' '.join(ls[3].split()[::-1]) return lst def main(lst): lst = remove_duplicated_columns(lst) lst = remove_empty_columns(lst) lst = remove_empty_rows(lst) lst = split_column_one_and_transform(lst) return lst" "from collections import OrderedDict from itertools import groupby def remove_duplicated_rows(lst): return list(OrderedDict(((tuple(x), x) for x in lst)).values()) def remove_empty_columns(lst): data = zip(*lst) data = [x for x in data if any(x)] return list(map(list, zip(*data))) def transpose(lst): return list(map(list, zip(*lst))) def remove_duplicated_columns(lst): data = zip(*lst) data = [x for x in data if not all_equal(x)] return list(map(list, zip(*data))) def all_equal(iterable): g = groupby(iterable) return next(g, True) and (not next(g, False)) def remove_empty_rows(lst): for ls in lst: if all_equal(ls) and ls[0] is None: lst.remove(ls) return lst def split_column_one_and_transform(lst): for ls in lst: ls[0] = ls[0].replace(',', '')[:-2] ls[1] = ls[1][::-1].replace('-', '', 1)[::-1] ls[2] = ls[2].split('[')[0] ls.pop(-1) return lst def main(lst): lst = remove_duplicated_columns(lst) lst = remove_empty_columns(lst) lst = remove_duplicated_rows(lst) lst = split_column_one_and_transform(lst) lst = transpose(lst) return lst" "from collections import OrderedDict from itertools import groupby def remove_duplicated_rows(lst): return list(OrderedDict(((tuple(x), x) for x in lst)).values()) def remove_empty_columns(lst): data = zip(*lst) data = [x for x in data if any(x)] return list(map(list, zip(*data))) def transpose(lst): return list(map(list, zip(*lst))) def remove_duplicated_columns(lst): data = zip(*lst) data = [x for x in data if not all_equal(x)] return list(map(list, zip(*data))) def all_equal(iterable): g = groupby(iterable) return next(g, True) and (not next(g, False)) def remove_empty_rows(lst): for ls in lst: if all_equal(ls) and ls[0] is None: lst.remove(ls) return lst def split_column_one_and_transform(lst): for ls in lst: ls.pop(1) ls[0] = str(int(float(ls[0]) * 100)) + '%' ls[1] = str(int(ls[1] == 'да')) ls[2] = ls[2].split('[')[0] ls[3] = ls[3].split('. ')[1] return lst def main(lst): lst = remove_duplicated_columns(lst) lst = remove_duplicated_rows(lst) lst = remove_empty_rows(lst) lst = split_column_one_and_transform(lst) return lst" "def cat(s): s = list(filter(None, s)) if s[1] == 'нет': s.append('N') else: s.append('Y') s[1] = s[0][:s[0].index('[')] + '@' s[1] = s[1] + s[0][s[0].index(']') + 1:s[0].index(';')] s[0] = s[0][s[0].index(';') + 1:] s[0] = s[0][6:] + '.' + s[0][3:5] + '.' + s[0][0:2] return s def main(s): for i in range(len(s)): s[i] = cat(s[i]) s.reverse() for x in s: if s.count(x) > 1: s.remove(x) s.reverse() return s" "def main(_list): for i in _list: if None in i: while None in i: i.remove(None) for j in range(len(i) - 1): if i.count(i[j]) > 1: i.reverse() i.remove(i[j]) i.reverse() i[0] = i[0].replace('/', '.') i[1] = str(round(float(i[1]), 2)) if len(i[1]) == 3: i[1] += '0' i[2] = i[2].title() i[3] = i[3][:i[3].find(']')] if [] in _list: while [] in _list: _list.remove([]) _list.sort() return _list" "def main(table): index = 0 for i in range(len(table)): if table[index][0] is None: table.remove(table[index]) else: index += 1 for i in range(len(table)): table[i].pop() table[i][3] = f'{float(table[i][3]):.{3}f}' if table[i][2] == 'Выполнено': table[i][2] = 'Да' else: table[i][2] = 'Нет' mail = table[i][1].find(']') + 1 table[i][1] = table[i][1][mail:len(table[i][1])] string = table[i][0] name1 = table[i][0][0:1] + '.' index1 = string.find(' ') + 1 string = string[index1:len(string)] name2 = string[0:string.find('.') + 1] index1 = string.find(' ') + 1 string = string[index1:len(string)] table[i][0] = string + ', ' + name1 + name2 table.sort() return table" "def main(tab): tab = newt(tab) tab = fourth(tab) tab = fifth(tab) newTab = [[0 for j in range(3)] for i in range(len(tab))] newTab = first(tab, newTab) newTab = second(tab, newTab) newTab = third(tab, newTab) return newTab def newt(tab): a = [] for i in range(len(tab)): if tab[i][0] is None: continue else: a.append(tab[i]) return a def first(tab, newTab): for i in range(len(tab)): newTab[i][0] = str(int(round(float(tab[i][0]) * 100, 0))) + '%' return newTab def second(tab, newTab): for i in range(len(tab)): b = tab[i][1].find('(') + 1 c = tab[i][1].find(')') telephone = tab[i][1][b:c] b = tab[i][1].find(')') + 2 c = b + 3 telephone += tab[i][1][b:c] b = tab[i][1].find('-') + 1 c = b + 4 telephone += tab[i][1][b:c] newTab[i][1] = telephone return newTab def third(tab, newTab): for i in range(len(tab)): surname = tab[i][1][:tab[i][1].find(',')] name = tab[i][1][tab[i][1].find(',') + 1:] name = name[1:2] name = name[::-1] newTab[i][2] = name + '. ' + surname return newTab def fourth(tab): a = [] b = [] for i in range(len(tab)): for j in range(i + 1, len(tab)): if tab[i][0] == tab[j][0]: counter = 0 fourth_1(tab, i, j, b) for i in range(len(tab)): if i in b: continue else: a.append(tab[i]) return a def fourth_1(tab, i, j, b): counter = 0 for k in range(len(tab[i])): if tab[i][k] == tab[j][k]: counter += 1 if counter == len(tab[i]): b.append(j) def fifth(tab): b = set() for i in range(len(tab[0])): for j in range(i + 1, len(tab[0])): if tab[0][i] == tab[0][j]: fifth_1(tab, i, j, b) a = [[0] for i in range(len(tab))] counter = True for i in range(len(tab[0])): if i in b: continue else: for j in range(len(tab)): if counter: a[j][0] = tab[j][i] else: a[j].append(tab[j][i]) counter = False return a def fifth_1(tab, i, j, b): counter = 0 for k in range(len(tab)): if tab[k][i] == tab[k][j]: counter += 1 if counter == len(tab): b.add(j)" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_duplicate_rows(table): result = [] for i in table: if i not in result: result.append(i) return result def split_str(seq, chunk, skip_tail=False): lst = [] if chunk <= len(seq): lst.extend([seq[:chunk]]) lst.extend(split_str(seq[chunk:], chunk, skip_tail)) elif not skip_tail and seq: lst.extend([seq]) return lst def transformer(i, value): if i == 0: name = value.split() name[0] = name[0][0] + '.' return f'{name[2]} {name[0] + name[1]}' if i == 1: replaced = value.replace('-', '') ad = split_str(replaced, 2) replaced = ad[2] + '.' + ad[1] + '.' + ad[0] return replaced if i == 2: digit_str = value.replace('%', '') digit = float(digit_str) / 100 return f'{digit:.2f}' if i == 3: (before, sep, after) = value.partition('[at]') return after def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_duplicate_rows(table)))" "def cat(s): s = list(filter(None, s)) s[0] = s[0][s[0].index('.') + 2:] + ' ' + s[0][:s[0].index(' ')] temp = s[1][8] + s[1][9] + '/' + s[1][3] s[1] = temp + s[1][4] + '/' + s[1][0] + s[1][1] s[2] = s[2][:s[2].index('[')] + '@' + s[2][s[2].index(']') + 1:] if s[3] == 'Выполнено': s[3] = 'Да' else: s[3] = 'Нет' s.pop(4) return s def main(s): for i in range(len(s)): s[i] = cat(s[i]) s.reverse() for x in s: if s.count(x) > 1: s.remove(x) s.reverse() s2 = [[row[i] for row in s] for i in range(len(s[0]))] return s2" "def transpose(s): s1 = [] s = [row for row in s if row[1] is not None] for i in range(len(s[0])): s1.append([]) for j in range(len(s)): s1[i].append(s[j][i]) return s1 def main(s): s = transpose(s) s = transpose(s) for row in s: row[2] = row[2].split(' ')[1] + ' ' + row[2].split(' ')[0] if row[1] == 'Не выполнено': row[1] = 'Нет' else: row[1] = 'Да' for row in s: b = row[0].split('|') row[0] = b[0][3:] k = b[1].index(']') + 1 b[1] = b[1][k:] row.insert(1, b[1]) return s" "import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] new_table = [] row1 = [] row2 = [] row3 = [] for i in data: i.pop(-1) i[0] = re.sub('\\[at\\].*', '', i[0]) if len(i[1]) == 2: i[1] = '0.0' + i[1][:-1] else: i[1] = '0.' + i[1][:-1] if len(i[1]) == 3: i[1] += '0' split = i[2].split(' ') i[2] = split[0] + ' ' + split[2] row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) new_table.append(row1) new_table.append(row2) new_table.append(row3) return new_table" "from datetime import datetime import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] row1 = [] row2 = [] row3 = [] for i in data: i.pop(1) i.pop(1) i[0] = re.sub('@.*', '', i[0]) split = i[1].split('!') i[1] = split[1][7:] date = datetime.strptime(split[0], '%d.%m.%Y') split[0] = date.strftime('%d.%m.%y') i.append(split[0]) row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) new_table.append(row1) new_table.append(row2) new_table.append(row3) return new_table" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def sus(table): for i in range(len(table)): (before, sep, after) = table[i][1].partition('!') table[i][1] = before table[i].append(after) return table def transformer(i, value): if i == 0: replaced = value.replace('[at]', '@') return replaced if i == 1: replaced = value.replace('(', '').replace(')', '').replace('-', '') return replaced if i == 2: return 'Да' if value == '1' else 'Нет' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(sus(delete_empty_rows(table))))" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0] is not None] data = [list(x) for x in tpls] new_table = [] row1 = [] row2 = [] row3 = [] for i in data: i.pop(-1) if i[0] == 'нет': i[0] = 'false' else: i[0] = 'true' split = i[1].split(':') if len(split[1]) == 2: i[1] = '0.0' + split[1][:-1] + '00' else: i[1] = '0.' + split[1][:-1] + '00' date = datetime.strptime(split[0], '%d-%m-%Y') i.append(date.strftime('%Y-%m-%d')) row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) new_table.append(row1) new_table.append(row2) new_table.append(row3) return new_table" "def change(s): s = list(filter(None, s)) for i in range(len(s)): if '/' in s[i]: s[i] = s[i].replace('/', '-') elif '.' in s[i]: s[i] = str(round(float(s[i]), 1)) elif '+' in s[i]: s[i] = s[i].replace(' ', '') s[i] = s[i].replace('+7', '') s[i] = s[i].replace('-', '') elif 'N' == s[i]: s[i] = 'Не выполнено' else: s[i] = 'Выполнено' return s def sort_key(s): return s[2] def main(s): for i in range(len(s)): s[i] = change(s[i]) s = list(filter(None, s)) s = sorted(s, key=sort_key) return s" "def main(table): a = [i for i in table if i[0] is not None] b = [a[0].index(i) for i in list(set(a[0]))] b.sort() c = [[i[b[0]], i[b[1]], i[b[2]], i[b[3]]] for i in a] d = [['{}-{}-{}'.format(i[0][-2:], i[0][-7:-5], i[0][:2]), i[1][4:], str(int((str(round(float(i[2]), 2)).split('.')[1] + '0')[:2])) + '%', i[3].split(']')[1]] for i in c] e = [[], [], [], []] for i in range(len(d)): e[0].append(d[i][0]) e[1].append(d[i][1]) e[2].append(d[i][2]) e[3].append(d[i][3]) return e" "from dataclasses import replace from xml.dom.minidom import Element def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): for row in table: del row[1] del row[1] del row[1] return table def rounding(value): temp = value - int(value) return int(value + temp) def transformer(i, value): if i == 0: value = value[:-3] + value[-2:] value = value.replace(' ', '') value = value.replace('(', '') value = value.replace(')', '-') return value if i == 1: name = value.split('@') return name[1] if i == 2: digit = rounding(float(value) * 100) digit_str = str(digit) + '%' return f'{digit_str}' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, str(table[i][j])) return table def main(table): return transpose(transform(delete_duplicate_columns(delete_empty_rows(table))))" "import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[1] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(2) i.pop(0) split = i[0].split(':') split1 = split[0].split(' ') i[0] = split1[1][:-2] + ' ' + split1[0] if len(i[1]) == 2: i[1] = '0.0' + i[1][:-1] + '0' else: i[1] = '0.' + i[1][:-1] + '0' i.append(re.sub('^.*@', '', i[2])) i[2] = split[1][7:10] + split[1][11:13] + split[1][14:] row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) row.append(i[3]) new_table.append(row) return new_table" "def deleteColumn(table): notEmptyCols = [] newTable = [] newRow = [] for col in range(len(table[0])): empty = False if table[0][col] is None: empty = True for row in range(len(table)): if not table[row][col] is None: empty = False if not empty: notEmptyCols.append(col) for i in range(len(table)): newRow.append([]) for j in notEmptyCols: newRow[i].append(table[i][j]) newTable.append(newRow[i]) return newTable def delDoubleRow(table): newTable = [] for row in table: double = False for i in range(len(newTable)): if row == newTable[i]: double = True if not double: newTable.append(row) return newTable def deleteRows(table): newTable = [] for row in table: empty = False if row[0] is None: empty = True for i in range(len(row)): if not row[i] is None: empty = False if not empty: newTable.append(row) return newTable def splitBySymbol(table): for row in table: row.append(row[1][row[1].index('!') + 1:]) row[1] = row[1][:row[1].index('!')] return table def transformContent(table): for row in table: for i in range(len(row)): if i == 0: row[i] = row[i].replace('-', '.') row[i] = row[i][:6] + row[i][8:] if i == 1: dot = row[i].index('.') row[i] = row[i][dot + 2:] + ' ' + row[i][:1] + '.' + row[i][dot - 1:dot + 1] if i == 2: row[i] = row[i].replace('[at]', '@') if i == 3: row[i] = row[i].replace('(', '').replace(')', '') row[i] = row[i][:10] + row[i][11:] return table def transpose(table): newTable = [] for col in range(len(table[0])): newTable.append([]) for row in table: newTable[col].append(row[col]) return newTable def main(table): return transpose(transformContent(splitBySymbol(deleteRows(delDoubleRow(deleteColumn(table))))))" "def main(a: list): i = 0 while i < len(a): del a[i][1] del a[i][1] del a[i][2] cell = a[i][0].split('|') a[i][0] = cell[1].replace('/', '.')[2:] a[i][1] = 'Выполнено' if a[i][1] == '1' else 'Не выполнено' a[i][2] = a[i][2][6:12] + a[i][2][13:15] a[i].append(str(round(float(cell[0]), 1))) i += 1 return a" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): for row in table: del row[5] for row in table: del row[2] for row in table: del row[1] return table def transformer(i, value): if i == 0: return value + '0' if i == 1: dig = value.split('-') return f'{dig[2][2:]}-{dig[1]}-{dig[0]}' if i == 2: replaced = value.replace('[at]', '@') return replaced if i == 3: value = value.replace('(', '').replace(') ', '-') dig = value.split('-') return f'{dig[0]}-{dig[1]}-{dig[2]}{dig[3]}' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transpose(transform(transpose(delete_duplicate_columns(delete_empty_rows(table)))))" "def delete_duplicate_rows(table): temp = [] [temp.append(x) for x in table if x not in temp] return temp def split_into_columns(table): res = [] for i in range(len(table)): t = [] s = table[i][0].split('&')[0] remove_last = s[:-2] t.append(remove_last) s = table[i][1] remove_last = s[:6] + s[8:] t.append(remove_last) t.append(table[i][0].split('&')[1].replace('[at]', '@')) res.append(t) return res def main(table): return delete_duplicate_rows(split_into_columns(table))" "def main(*args): unzip = [*args] data = [x for i in unzip for x in i] del_col(data) del_dubl(data) del_line(data) data = transformation(data) data = transpose(data) return data def del_col(data): for line in data: del line[0:2] def del_dubl(data): for line in data: count = data.count(line) if count > 1: for i in range(count - 1): data.remove(line) def del_line(data): for line in data: if line[0] is None: data.remove(line) def transformation(data): new_data = [] for line in data: line = split(line) line[1] = email_conversion(line[1]) line[2] = data_conversion(line[2]) line[0] = name_conversion(line[0]) new_data.append(line) new_data.sort() return new_data def split(line): call = line[1].split('#') line[1] = call[1] line.append(call[0]) return line def email_conversion(email): email = email.split('[at]') email = email[0] + '@' + email[1] return email def data_conversion(date): date = date.split('/') date = date[2] + '-' + date[1] + '-' + date[0] return date def name_conversion(name): name = name.split(' ') name = name[1][:2] + ' ' + name[0] return name def transpose(data): new_data = [[data[j][i] for j in range(len(data))] for i in range(len(data[0]))] return new_data" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_duplicate_columns(table): for row in table: del row[4] return table def transformer(i, value): if i == 0: name = value.split(',') return f'{name[0]}' if i == 1: replaced = value.replace('+7 ', ' (').replace(' ', ') ').replace(' (', '(') return replaced[1:] if i == 2: data = value.replace('/', '.') return data if i == 3: return 'Выполнено' if value == 'Y' else 'Не выполнено' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def takeSecond(elem): return elem[0] def main(table): table = delete_duplicate_columns(table) table = sorted(table) table = transform(transpose(table)) return table" "def main(a: list): i = 0 while i < len(a): del a[i][1] del a[i][2] del a[i][3] a[i][0] = a[i][0][6:12] + '-' + a[i][0][-2:] a[i][1] = a[i][1][-2:] + '/' + a[i][1][5:7] + '/' + a[i][1][:4] a[i][2] = 'Да' if a[i][2] == 'true' else 'Нет' a[i][3] += '0' i += 1 return a" "def main(inp_tbl): out_tbl = [] for (i, line) in enumerate(inp_tbl): line = [el for el in line if el] if len(line) > 0: name = line[1].split(' ') res_col = name[2].split('&') cent = line[0] b = ',' c = str(res_col[1]) d = c.replace('/', '.', 3) res_col[1] = d line = [str(round(float(cent), 1)), f'{res_col[0] + b} {name[0][:1]}.{name[1]}', res_col[1]] out_tbl.append(line) return out_tbl" "from datetime import datetime import pprint def main(table): lst = remove(table) for i in range(len(table)): table[i][0] = str(reverse(table[i][1])) table[i][1] = split(table[i][2]) table[i][2] = index(table[i][3]) ans = [list(x) for x in zip(*lst)] ans.pop(3) return ans def remove(ls): res = [] for i in ls: if i not in res: res.append(i) return res def index(num): num = round(float(num), 1) return str(num) def reverse(date): date = datetime.strptime(date, '%d.%m.%y') date = date.strftime('%y-%m-%d') return date def split(mail): mail = mail.split('[at]')[1] return mail" "def rem(x): i = 0 for i in range(len(x) - 1): if x[i][0] is None: x.remove(x[i]) i = 0 for i in range(len(x)): if x[i][0] is None: x.remove(x[i]) return x def cop(x): i = 0 j = 0 k = 0 temp = [] for i in x: if i not in temp: temp.append(i) x = temp return x def main(x): x = cop(x) x = rem(x) for i in range(len(x)): for j in range(len(x[i])): if j == 0: x[i][j] = x[i][j].split('[at]')[1] if j == 1: x[i][j] = x[i][j].split(' ')[1] if j == 2: x[i][j] = x[i][j].split(' ')[1] + ' ' + x[i][j].split(' ')[0] if j == 3: if x[i][j] == 'Выполнено': x[i][j] = 'true' elif x[i][j] == 'Не выполнено': x[i][j] = 'false' return x" "def main(tbl): result = [] for (one, two, three) in tbl: if one is None or two is None or three is None: continue else: result.append([str(round(float(one), 1)), '/'.join([d[-2:] for d in two.split('-')]), 'Да' if three == 'true' else 'Нет']) tbl = result return tbl" "import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data] dct = list(dict.fromkeys(tpls)) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(1) i.pop(-1) i[1] = re.sub('^.*\\[at\\]', '', i[1]) split = i[0].split(';') i.append(split[0][0:12]) if i[2] == 'Не выполнено': i[2] = 'нет' else: i[2] = 'да' i[0] = re.sub('^.*;', '', i[0]) i[0] = str(round(float(i[0]), 1)) if len(i[0]) == 2: i[0] = i[0] + '0' row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) new_table.append(row) return data" "def main(table): for row in table: del row[3] for i in range(len(table)): for j in range(len(table)): if i != j and table[i] == table[j]: table[j] = [] table = list(filter(lambda table: table != [], table)) for row in table: digit_str = row[0].replace('%', '') digit = float(digit_str) / 100 row[0] = f'{digit:.3f}' a = row[1][0:3] b = row[1][3:6] c = row[1][6:8] d = row[1][8:10] row[1] = '(' + a + ')' + ' ' + b + '-' + c + '-' + d if row[2] == 'Нет': row[2] = '0' elif row[2] == 'Да': row[2] = '1' return table" "def main(_list): for line in _list: if None in line: while None in line: line.remove(None) if len(line) == 0: continue for i in range(len(line) - 1): if line.count(line[i]) > 1: a = line[i] line.reverse() line.remove(a) line.reverse() line[0] = line[0].split() line[0] = line[0][2] + ' ' + line[0][0] line[2] = line[2].replace('1', 'да') line[2] = line[2].replace('0', 'нет') line[1] = line[1].replace('.', '-') if [] in _list: while [] in _list: _list.remove([]) _list = list(map(list, zip(*_list))) return _list" "import itertools def main(table): table = list((k for (k, _) in itertools.groupby(table) if k.count(None) == 0)) for x in table: if table.count(x) > 1 or table.count(None) > 0: table.remove(x) for i in table: i[0] = i[0].split(' ')[-1] i[1] = str(int(round(float(i[1]), 2) * 100)) + '%' i[2] = 'Выполнено' if i[2] == 'Y' else 'Не выполнено' i[3] = i[3][5:8] + '-' + i[3][8:] table = sorted(table, key=lambda s: s[3]) table = list(map(list, zip(*table))) return table" "def main(_list): if [None, None] in _list: while [None, None] in _list: _list.remove([None, None]) new_list = [] for line in _list: new_sub_list = [] first = line[0][line[0].find(']') + 1:] second = line[0][line[0].find(')') + 1:line[0].find('&')].strip() second = second.replace('-', '') third = line[1].replace('%', '') third = round(float(third) / 100, 1) new_sub_list.append(first) new_sub_list.append(second) new_sub_list.append(str(third)) new_list.append(new_sub_list) return new_list" "def main(a: list): i = len(a) - 1 while i >= 0: if a.count(a[i]) > 1: del a[i] i -= 1 res = [[], [], [], []] for i in range(len(a)): cell = a[i][2].split('|') res[0].append(str(round(float(cell[0]) * 100)) + '%') res[1].append(cell[1][:cell[1].find('@')]) name = a[i][3].split(' ') res[2].append(name[2] + ', ' + name[0][:1] + '.' + name[1]) res[3].append(a[i][4].replace('.', '/')) return res" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_columns(table): return table def delete_empty_rows(table): return [col for col in table if not all((v is None for v in col))] def delete_duplicate_rows(table): seen = [] for row in table: if row[1] not in seen: seen.append(row[1]) else: row[0] = row[1] = row[2] = None return table def transformer(i, value): if i == 0: return 'Да' if value == '1' else 'Нет' if i == 1: replaced = value.replace(') ', '-').replace('(', '') return replaced[0:] if i == 2: name = value.split(',') return name[0] def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def sort_by_sec(table): for row in table: temp = row[0] row[0] = row[2] row[2] = temp table = sorted(table) for row in table: temp = row[0] row[0] = row[2] row[2] = temp for row in table: temp = row[1] row[1] = row[2] row[2] = temp return table def split_by_sep(table): for row in table: temp = row[1].split(';') row[0] = temp[0] row[1] = temp[1] return table def main(table): return sort_by_sec(transform(split_by_sep(delete_empty_rows(delete_empty_columns(delete_duplicate_rows(table))))))" "def delete_duplicate(table): for row in table: del row[5] return table def delete_none(table): new_table = [] for k in range(len(table)): result = [i for i in table[k] if i is not None] new_table.append(result) table = new_table return table def delete_duplicate_value(table): new_new_table = [] for values in table: if values not in new_new_table: new_new_table.append(values) table = new_new_table return table def stripper(table): for row in table: row[0] = row[0].split('&') row.append(row[0][0]) row.append(row[0][1]) del row[0] row.insert(0, row.pop()) row.insert(1, row.pop()) row[0] = float(row[0]) row[0] = '{:.0%}'.format(row[0]) row[0] = str(row[0]) if row[3] == '1': row[3] = 'true' elif row[3] == '0': row[3] = 'false' return table def new_stripper(table): for row in table: row[2] = row[2].split(',') row[2].insert(0, row[2].pop()) row[2] = '.'.join(row[2]) row[2] = row[2].replace(' ', '') row[2] = row[2][:1] + '. ' + row[2][5:] row[1] = row[1][2:] return table def main(table): return new_stripper(stripper(delete_duplicate_value(delete_none(delete_duplicate(table)))))" "def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): out = [] for row in table: if row not in out: out.append(row) return out def transformer(i, value): if i == 0: name = value.split() name[0] = name[0][:-2] return f'{name[1]} {name[0]}' if i == 1: replaced = value.replace('.', '-') return replaced if i == 2: replaced = value.replace('-', ' ', 1) return replaced if i == 3: return '1' if value == 'Да' else '0' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(delete_duplicate_columns(delete_empty_rows(table)))" "def delete_duplicate_columns(table): for row in table: del row[3] return table def delete_duplicate_row(table): result = [] for i in table: if i not in result: result.append(i) return result def transformer(i, value): if i == 0: replaced = value.replace('/', '-') return replaced if i == 2: digit_str = value.replace('%', '') digit = float(digit_str) / 100 return f'{digit:.2f}' if i == 1: replaced = value.replace('[at]', '@') return replaced def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(delete_duplicate_row(delete_duplicate_columns(table)))" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def sort_strings(table): return sorted(table) def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_rows(table): result = [] for i in table: if i not in result: result.append(i) return result def delete_duplicate_columns(table): for row in table: del row[3] return table def transformer(i, value): if i == 0: replaced = value.replace(',', '') return replaced[:-2] if i == 1: name = value.split('/') return f""{name[2]}{'.'}{name[1]}{'.'}{name[0]}"" if i == 2: name = value.split('@') return f'{name[1]}' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transpose(transform(sort_strings(delete_duplicate_columns(delete_empty_rows(delete_duplicate_rows(table))))))" "def new_list(x): i = 0 set = [] while x[0][i] not in set: set.append(x[0][i]) i += 1 for row in x: row.pop(i) return x def substitution(x): for row in range(len(x)): x[row][0] = 'нет' if x[row][0] == 'N' else 'да' x[row][1] = '%.2f' % float(x[row][1]) s = x[row][2] x[row][2] = s[6:] + '-' + s[3:5] + '-' + s[0:2] return x def delete_empty_lines(x): nt = [] for i in x: if any(i): nt.append(i) return nt def main(x): x = delete_empty_lines(x) x = new_list(x) x = substitution(x) return x" "import time def main(r): anss = [] for i in r: if i[0]: ans = [] del i[0] ans.append(i[0]) i[1] = i[1].split(':') ans.append(i[1][0].replace(' ', '')) i[1][1] = i[1][1].split('.') ans.append(i[1][1][1].lstrip()) ans[0] = '.'.join(ans[0].split('.')[::-1]) anss.append(ans) anss.sort(key=lambda x: x[2]) return anss" "import math def deleteHollow(x): temp = [] for item in x: if item[0] is not None and item[1] is not None: temp.append(item) return temp def divide(x): temp = [] temp2 = [] for item in x: str = item[0].split(':') str.append(item[1]) temp.append(str) return temp def morph(x): temp = [] temp2 = [] for item in x: item[0] = item[0][2:].replace('/', '-') item[1] = str(math.ceil(round(float(item[1]), 2) * 100)) + '%' item[2] = item[2].replace('[at]', '@') temp2.append(item[0]) temp2.append(item[2]) temp2.append(item[1]) temp.append(temp2) temp2 = [] return temp def transpon(x): temp = [[x[j][i] for j in range(len(x))] for i in range(len(x[0]))] return temp def main(x): x = deleteHollow(x) x = divide(x) x = morph(x) x = transpon(x) return x" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[0] i.insert(a, s[1]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('-') i[n] = f'{hop[0]}.{hop[1]}.{hop[2]}' return lst def format_procent(lst, n): for i in lst: i[n] = i[n].replace('%', '') j = int(i[n]) / 100 i[n] = '{0:.4f}'.format(j) return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = splt(lst, 1, 1, sep='&') lst = format(lst, 0) lst = format_data(lst, 1) lst = format_procent(lst, 2) lst.sort(key=lambda x: x[0]) lst = transpose(lst) return lst" "def deleet(sam_list): result = [] for i in sam_list: if i not in result: result.append(i) return result def transformer(i, value): if i == 0: return value[4:] if i == 1: value = value.split('#') value[1] = value[1].replace('-', '/') return value[1] if i == 2: return value.replace('[at]', '@') if i == 3: value = value.split('#') if value[0] == 'да': return 'Y' else: return 'N' def transform(table): for i in range(len(table)): table[i][3] = transformer(3, table[i][1]) for i in range(len(table)): for j in range(len(table[i]) - 1): table[i][j] = transformer(j, table[i][j]) return table def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def main(table): return transpose(sorted(transform(deleet(table))))" "import re def deleteEmptyColumn(data): newData = [] for i in range(len(data)): oldLine = data[i] newLine = [] for j in range(len(oldLine)): if oldLine[j] is not None: newLine.append(oldLine[j]) newData.append(newLine) return newData def deleteSameColumn(data): newData = [] for i in range(len(data)): newData.append(list(set(data[i]))) return newData def deleteSameLine(data): for i in range(len(data)): line = data[i] for j in range(len(data)): compareLine = data[j] if i != j and set(line) == set(compareLine): data.pop(j) return deleteSameLine(data) return data def transformDateFormat(data): for i in range(len(data)): line = data[i] for j in range(len(line)): val = line[j] if re.match('\\d{4}\\.\\d{2}\\.\\d{2}', val) is not None: line[j] = '/'.join(val.split('.')[::-1]) return data def getTransformedName(name): splittedName = name.split(' ') return splittedName[2] + ' ' + splittedName[0][0] + '.' + splittedName[1] def addAtToMail(mail): (user, host) = mail.split('@') return user + '[at]' + host def splitExclamativeSign(data): newData = [] for i in range(len(data)): (firstVal, secondVal) = data[i] if '!' in firstVal: (name, mail) = firstVal.split('!') a = getTransformedName(name) newData.append([a, addAtToMail(mail), secondVal]) else: (name, mail) = secondVal.split('!') a = getTransformedName(name) newData.append([a, addAtToMail(mail), firstVal]) return newData def main(x): a = deleteSameColumn(deleteEmptyColumn(x)) b = transformDateFormat(deleteSameLine(a)) return splitExclamativeSign(b)" "def main(table): newTable = [[], [], []] dupl = [] for row in table: if row in dupl: continue dupl.append(row) uid = row[1].split('&')[1][4:].replace('-', '') newTable[0].append(uid) email = row[1].split('&')[0] newTable[1].append(email[:email.find('@')]) newTable[2].append('%.2f' % float(row[2])) for i in range(1, len(newTable[0])): for j in range(0, len(newTable[0])): uid1 = int(newTable[0][j - 1]) uid2 = int(newTable[0][i]) if uid1 > uid2: for item in newTable: (item[j - 1], item[i]) = (item[i], item[j - 1]) return newTable" "def remove_extra_rows(table): new_table = [] for i in range(len(table)): if table[i] not in new_table and table[i] != [None] * len(table[i]): new_table.append(table[i]) return new_table def transpose(table): new_table = [] for i in range(len(table[0])): line = [] for j in range(len(table)): line.append(table[j][i]) new_table.append(line) return new_table def transform_view(table): for i in range(len(table)): date = table[i][0].split('.') date = [date[-1][2:], date[1], date[0]] table[i][0] = '. '.join(date) table[i][0] = table[i][0].lstrip(' .') table[i][0] = table[i][0].lstrip(' .') table[i][0] = table[i][0][3:] table[i][0] = table[i][0][-1:] + '. ' + table[i][0][0:-2] table[i][1] = table[i][1].split()[-1] table[i][1] = table[i][1].split('[at]')[1] table[i][2] = '%.4f' % float(table[i][2]) return table def main(table): table = transpose(table) table = remove_extra_rows(table) table = transpose(table) table = remove_extra_rows(table) table = transform_view(table) return table" "def main(table): for row in table: del row[2] del row[2] new_table = list() for row in table: if row not in new_table and row[0] is not None: new_table.append(row) table = new_table for row in table: row[0] = '{:.0%}'.format(float(row[0])) row[1] = row[1].replace('да', 'Y').replace('нет', 'N') row[2] = row[2].replace(row[2][-4:], row[2][-2:]).replace('-', '.') return table" "def del_row(s): s1 = [] for row in s: if row not in s1: s1.append(row) return s1 def transpose(s): s1 = [] for i in range(len(s[0])): s1.append([]) for j in range(len(s)): s1[i].append(s[j][i]) return s1 def main(s): s = transpose(s) s = [row for row in s if row[0] is not None] s = del_row(s) s = transpose(s) for row in s: x = row[1].split('-') row[1] = x[2] + '.' + x[1] + '.' + x[0][2:] b = row[0].split('|') row[0] = b[1][3:6] + '-' + b[1][6:8] + '-' + b[1][8:] b[0] = round(float(b[0]), 1) b[0] = str(b[0]) row.insert(1, b[0]) s = transpose(s) return s" "def main(x): x1 = [] for i in x: if i not in x1 and i != [None, None, None, None]: x1.append(i) x = x1 for i in range(0, len(x)): x4 = [] for k in range(0, len(x[i])): if x[i][k] not in x4: x4.append(x[i][k]) if x4[0] == 'N': x[i] = ['Не выполнено'] else: x[i] = ['Выполнено'] x[i].append(preb(x4[1])) x[i].append(x4[2].replace(' (', '').replace(') ', '').replace('-', '')) x.sort(key=custom_key) return tran(x) def preb(x): if x == '100%': return '1.000' elif len(x) == 2: return '0.0' + x[:1] + '00' else: return '0.' + x[:2] + '00' def tran(x): (x1, x2, x3) = ([], [], []) for i in range(0, len(x)): x1.append(x[i][0]) x2.append(x[i][1]) x3.append(x[i][2]) return [x1, x2, x3] def custom_key(x): return x[2]" "import datetime def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def transformer(i, value): if i == 0: index1 = value.find('[') replaced = value.replace(value[index1:len(value)], '') return replaced if i == 1: digit = float(value) digit_str = round(digit, 1) digit_str = str(digit_str) return digit_str if i == 2: date = value date = date[:6] + date[8:] return date def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def transform1(table): for i in range(len(table)): for j in range(len(table[i])): if j == 2: table[i][j] = datetime.datetime.strptime(table[i][j], '%Y-%m-%d').strftime('%d-%m-%Y') return table def tablesort(table): sortedtable = sorted(table, key=lambda table: table[2]) return sortedtable def main(table): return transform(transpose(tablesort(transform1(delete_empty_rows(table)))))" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): for row in table: del row[2] return table def transformer(i, value): if i == 0: replaced = value.replace(' ', '').replace('-', '').replace('+', '') return replaced[1:] if i == 1: digit_str = value.replace('%', '') digit = float(digit_str) / 100 return f'{digit:.2f}' if i == 2: name = value.split() return f'{name[1]} {name[0]}' if i == 3: return 'Выполнено' if value == 'Y' else 'Не выполнено' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_duplicate_columns(delete_empty_rows(table))))" "def del_double(a): ua = [] for i in range(len(a)): if not a[i] in ua: ua.append(a[i]) return ua def form0(form): return form[:form.find('.') + 1] def form1(form): return str(int(float(form) * 100)) + '%' def form2(form): if form == 'true': return 'да' else: return 'нет' def form3(form): return form[form.find('@') + 1:] def former(table): for i in range(len(table)): for j in range(len(table[0])): if j == 0: table[i][j] = form0(table[i][j]) elif j == 1: table[i][j] = form1(table[i][j]) elif j == 2: table[i][j] = form2(table[i][j]) elif j == 3: table[i][j] = form3(table[i][j]) return table def main(table): return former(del_double(table))" "def main(table): pars = set() result = [] for (num, rate, data) in table: pars_res = [] if data in pars or data is None: continue done = num.split(':')[0] if done == 'N': pars_res.append('Не выполнено') else: pars_res.append('Выполнено') phone = num.split(':')[1] phone = phone.split(' ')[2] pars_res.append(phone) pars_res.append(str(round(float(rate), 1))) date = data.replace('/', '-') pars_res.append(date) if pars_res not in result: result.append(pars_res) return [[result[i][j] for i in range(len(result))] for j in range(len(result[0]))] table = [['N:+7 075 271-61-82', '0.360', '04/12/10'], [None, None, None], ['N:+7 608 526-34-80', '0.135', '03/01/17'], ['N:+7 608 526-34-80', '0.135', '03/01/17'], ['N:+7 608 526-34-80', '0.135', '03/01/17'], ['N:+7 999 497-99-38', '0.564', '03/12/18']] main(table)" "def main(table): for row in table: del row[1] new_table = list() for row in table: if row not in new_table: new_table.append(row) table = new_table for row in table: (number, telephone) = row[0].split('&') row.insert(0, telephone.replace(' ', '')) row[1] = str('{:.4f}'.format(float(number))) row[2] = row[2].split('[')[0] table = list(map(list, zip(*table))) return table" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[0] i.insert(a, s[1]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('/') i[n] = f'{hop[2]}.{hop[1]}.{hop[0]}' return lst def format_procent(lst, n): for i in lst: i[n] = i[n].replace('%', '') j = float(i[n]) i[n] = '{0:.4f}'.format(j) return lst def surname_format(lst, n): for i in lst: i[n] = i[n].split()[0] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][3:6] + ' ' + i[n][7:13] + i[n][14:] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = format_data(lst, 1) lst = format_procent(lst, 0) lst = surname_format(lst, 2) lst = telephone_format(lst, 3) lst = transpose(lst) return lst" "def main(x): x1 = [] for i in x: if i not in x1: x1.append(i) x = x1 (x1, x2, x3) = ([], [], []) for i in range(0, len(x)): x5 = [] for j in range(0, len(x[i])): if x[i][j] not in x5: x5.append(x[i][j]) x[i] = x5 x4 = x[i][0].split('.')[::-1] x1.append(x4[0] + '-' + x4[1] + '-' + x4[2]) x2.append(x[i][1][x[i][1].find(' ') + 1:]) x3.append(x[i][2][:x[i][2].find(' ')]) x = [x1, x2, x3] return x" "def main(x): sp = [list(filter(lambda k: k is not None, i)) for i in x] sp = list(filter(lambda k: k != [], sp)) sp = [[sp[j][i] for j in range(len(sp))] for i in range(len(sp[0]))] for i in range(len(sp)): a = sp.pop() if a not in sp: sp.append(a) first = sp[0] array = [] for i in first: array.append(i.replace('.', '-')) sp[0] = array first = sp[1] array = [] for i in first: a = float(i) array.append(str(round(round(a, 2) * 100)) + '%') sp[1] = array first = sp[2] array = [] for i in first: array.append(i.replace('[at]', '@')) sp[2] = array return sp" "def change_row(row): row[0] = row[0].replace('@', '[at]') row[1] = row[1][:-2] + '-' + row[1][-2:] row[2] = 'Выполнено' if row[2] == 'Да' else 'Не выполнено' row[3] = str(round(float(row[3]), 2)) row[3] += '0' * (4 - len(row[3])) return row def main(table): new = [] for row in table: if row in new: continue new.append(row) for i in range(len(new)): new[i] = change_row(new[i]) new_table = [[None for _ in range(len(new))] for _ in range(len(new[0]))] for (i, row) in enumerate(new): for (j, cell) in enumerate(row): new_table[j][i] = cell return new_table" "def change_row(row): buff = row[0].split('!') num = buff[1] date = buff[0] num = num[:3] + '-' + num[3:6] + '-' + num[6:] date = date.split('/') date = reversed(date) date = '-'.join(date) row[0] = num row[1] = date row[2] = 'Выполнено' if row[2] == 'Да' else 'Не выполнено' row[3] = str(round(float(row[3]), 1)) return row def main(table): new = [] for row in table: if row in new: continue new.append(row) for i in range(len(new)): new[i] = change_row(new[i]) new = sorted(new, key=lambda x: x[0]) return new" "def change_row(row): buff = row[1].split('|') name = buff[0] date = buff[1] date = date.split('.') date = '-'.join(date) row[0] = date row[1] = name[:2] + name[4:] row[2] = row[2][row[2].find(']') + 1:] return row def main(table): new = [] for row in table: if row[2] is None: continue row.pop() if row in new: continue new.append(row) for i in range(len(new)): new[i] = change_row(new[i]) new_table = [[None for _ in range(len(new))] for _ in range(len(new[0]))] for (i, row) in enumerate(new): for (j, cell) in enumerate(row): new_table[j][i] = cell return new_table" "def removeEmptyRows(table): emptyLines = [] for i in range(len(table)): if table[i][0] is None: emptyLines.append(i) for i in emptyLines: table.pop(i) def removeEmptyColumns(table): emptyColumns = [] for i in range(len(table[0])): if table[0][i] is None: emptyColumns.append(i) for column in emptyColumns: for i in range(len(table)): table[i].pop(column) def convertFstColumn(table): for i in range(len(table)): if table[i][0] == 'true': table[i][0] = 'Y' elif table[i][0] == 'false': table[i][0] = 'N' def convertScdColumn(table): for i in range(len(table)): strings = table[i][1].split(':') table[i].insert(1, '') table[i][1] = strings[0].split('@')[1] date = strings[1].split('/')[::-1] table[i][2] = '-'.join(date) def convertLastColumn(table): for i in range(len(table)): num = int(''.join((c for c in table[i][-1] if c.isdigit()))) / 100 table[i][-1] = str('%.2f' % num) def main(table): removeEmptyRows(table) removeEmptyColumns(table) convertFstColumn(table) convertScdColumn(table) convertLastColumn(table) return table" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[0] i.insert(a, s[1]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('-') i[n] = f'{hop[2]}/{hop[1]}/{hop[0]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('Да', 'Выполнено') i[n] = i[n].replace('Нет', 'Не выполнено') return lst def format_procent(lst, n): for i in lst: i[n] = i[n].replace('%', '') j = float(i[n]) i[n] = '{0:.4f}'.format(j) return lst def surname_format(lst, n): for i in lst: i[n] = i[n].split()[1] + ' ' + i[n].split()[0] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][3:6] + ' ' + i[n][7:13] + i[n][14:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('[at]')[0] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = format_data(lst, 0) lst = true_format(lst, 1) lst = email_format(lst, 3) lst = surname_format(lst, 2) lst = transpose(lst) return lst" "def main(x): x = changeEmail(x) x = changePhone(x) x = changePercent(x) x = changeName(x) x = reverseArray(x) return x def changeEmail(array): for i in range(len(array)): email = array[i][0] razd = '[at]' result = email.split(razd, 1)[0] array[i][0] = result return array def changePhone(array): for i in range(len(array)): array[i][1] = ''.join(array[i][1][5] + array[i][1][6] + array[i][1][7] + '-' + array[i][1][8] + array[i][1][9] + '-' + array[i][1][10] + array[i][1][11]) return array def changePercent(array): for i in range(len(array)): array[i][2] = array[i][2].replace('%', '') if len(array[i][2]) == 2: array[i][2] = ''.join('0.' + array[i][2] + '0') if len(array[i][2]) == 1: array[i][2] = ''.join('0.0' + array[i][2] + '0') return array def changeName(array): for i in range(len(array)): name = ''.join(array[i][3][0]) surname = array[i][3][5:] array[i][3] = ''.join(surname + ' ' + name + '.') return array def reverseArray(array): rotated = [] for i in range(len(array)): rotated.append(array[i][0]) rotated1 = [] for i in range(len(array)): rotated1.append(array[i][1]) rotated2 = [] for i in range(len(array)): rotated2.append(array[i][2]) rotated3 = [] for i in range(len(array)): rotated3.append(array[i][3]) rotated4 = [] rotated4.append(rotated) rotated4.append(rotated1) rotated4.append(rotated2) rotated4.append(rotated3) return rotated4" "def delete_duplicate_columns(table): tableT = list(map(list, zip(*table))) for (i, row1) in enumerate(tableT): for (j, row2) in enumerate(tableT): if row1 == row2 and i != j: del tableT[j] return list(map(list, zip(*tableT))) def delete_empty_columns(table): tableT = list(map(list, zip(*table))) for (i, row) in enumerate(tableT): if row == [None] * len(row): del tableT[i] return list(map(list, zip(*tableT))) def delete_duplicate_rows(table): for (i, row1) in enumerate(table): for (j, row2) in enumerate(table): if row1 == row2 and i < j: table[j] = [None] * len(table[j]) return table def delete_empty_rows(table): table_cp = table.copy() deleted = 0 for (i, row) in enumerate(table): if row == [None] * len(row): del table_cp[i - deleted] deleted += 1 return table_cp def transformer(i, value): if i == 0: return value.split(' ')[0] if i == 1: return value[0:3] + '-' + value[3:6] + '-' + value[6:] if i == 2: if value == 'true': return '1' elif value == 'false': return '0' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def sort_table(table): table.sort(key=lambda x: x[1]) return table def main(table): table = sort_table(transform(delete_empty_rows(delete_duplicate_rows(delete_empty_columns(delete_duplicate_columns(table)))))) return table" "def main(table): parsed = set() (state, percent, man, end1) = ([], [], [], []) for (first, name1, name2) in table: if name1 in parsed or first is None: continue end = [] parsed.add(name1) h1 = first.split(';') if h1[0] == 'Да': h1[0] = 'Выполнено' else: h1[0] = 'Не выполнено' h1[1] = h1[1] + '00' h2 = name1.split(' ') name1 = f'{h2[0][0]}.{h2[1]} {h2[2]}' end.append(h1[0]) end.append(h1[1]) end.append(name1) end1.append(end) return end1" "import operator def main(table): parsed = set() newtable = [] for (_, mail, name, _, sphone) in table: if mail in parsed or mail is None: continue parsed.add(mail) domain = mail.split('[at]')[-1] (num, fio) = name.split('&') num = f'{num}0' fio = fio.replace('\n', ' ').split(' ') fio = ' '.join(fio[::-1]) phone = f'{sphone[2:5]} {sphone[5:8]}-{sphone[8:]}' newtable.append([domain, num, phone, fio]) return sorted(newtable, key=operator.itemgetter(2))" "def split(table): new_table = [] for row in table: col = row[2].split(';') row[2] = col[0] row.append(col[1]) new_table.append(row) return new_table def transform(table): new_table = [] for row in table: new_row = row string = row[0].split(' ') new_row[0] = string[0] + ' ' + string[2] new_row[1] = row[1][:row[1].index('[at]')] num = str(round(float(row[2]), 4)) num += '0' * (5 - len(num[num.index('.'):])) new_row[2] = num data = row[3].split('/') data.reverse() new_row[3] = '/'.join(data) new_table.append(new_row) return new_table def sort(table): return sorted(table, key=lambda x: x[1]) def transpose(table): new_table = [] for i in range(len(table[0])): new_table.append([]) for j in range(len(table)): new_table[i].append(table[j][i]) return new_table def main(table): return transpose(sort(transform(split(table))))" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('-') i[n] = f'{hop[2]}/{hop[1]}/{hop[0]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('да', 'Y') i[n] = i[n].replace('нет', 'N') return lst def format_procent(lst, n): for i in lst: i[n] = str(int(float(i[n]) * 100)) + '%' return lst def surname_format(lst, n): for i in lst: i[n] = i[n].split()[1] + ' ' + i[n].split()[0] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][:12] + '-' + i[n][12:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('[at]')[1] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = splt(lst, 1, 1, sep='&') lst = true_format(lst, 3) lst = email_format(lst, 0) lst = format_procent(lst, 1) lst = telephone_format(lst, 2) lst = transpose(lst) return lst" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('-') i[n] = f'{hop[2]}/{hop[1]}/{hop[0]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('0', 'false') i[n] = i[n].replace('1', 'true') return lst def format_procent(lst, n): for i in lst: i[n] = round(float(i[n]), 2) i[n] = '{0:.2f}'.format(i[n]) return lst def surname_format(lst, n): for i in lst: i[n] = i[n].split()[1] + ' ' + i[n].split()[0] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][:12] + '-' + i[n][12:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('[at]')[1] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = format_data(lst, 0) lst = true_format(lst, 2) lst = format_procent(lst, 1) lst = transpose(lst) return lst" "def delete_empty_col_rows(table): new_table = [] for i in table: list = [x for x in i if x is not None] if list: new_table.append(list) return new_table def delete_duplicates(table): new_table = [] index = 0 for i in table: for j in i: if i.count(j) > 1: i.remove(j) new_table.append(i) return new_table def transmation_data(table): new_table = [] for i in table: list = [] for j in range(0, len(i), 1): if j == 0: st = i[j] list.append(st.replace('-', '').replace('(', '').replace(' ', '').replace(')', '')) if j == 1: st = i[j] st2 = ' ' + st.split()[2] list.append(st.split()[0][0] + '.' + st.split()[1] + st2) if j == 2: ch = str(round(float(i[j]), 2)) if len(ch) < 4: list.append(ch + '0') else: list.append(ch) if j == 3: st = '' for k in range(0, str(i[j]).find('['), 1): st += i[j][k] list.append(st) new_table.append(list) return new_table def main(h): return transmation_data(delete_duplicates(delete_empty_col_rows(h)))" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('/') i[n] = f'{hop[2][2:]}-{hop[1]}-{hop[0]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('true', 'да') i[n] = i[n].replace('false', 'нет') return lst def format_procent(lst, n): for i in lst: i[n] = round(float(i[n]), 2) i[n] = '{0:.2f}'.format(i[n]) return lst def surname_format(lst, n): for i in lst: i[n] = i[n].split()[0] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n].replace(' ', '') i[n] = i[n].replace('-', '') return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('[at]')[1] return lst def main(lst): lst = format_data(lst, 3) lst = true_format(lst, 0) lst = surname_format(lst, 1) lst = telephone_format(lst, 2) lst = transpose(lst) return lst" "import re def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def transformer(i, value): if i == 0: replaced = value.split('.') return replaced[2] + '.' + replaced[1] + '.' + replaced[0] if i == 1: return value if i == 2: return value if i == 3: res = str(f'{round(float(value), 2):.{2}f}')[2:] + '%' if res[0] == '0': return res[1:] return str(f'{round(float(value), 2):.{2}f}')[2:] + '%' def transform(table): for i in range(len(table)): for j in range(len(table[i]) + 1): if j == 1: mid = table[i][j].split('#') table[i].insert(2, mid[0][:3] + '-' + mid[0][3:5] + '-' + mid[0][5:]) exr = '([\\w.]{2})\\w.\\s([\\w]*)' matches = re.findall(exr, mid[1]) table[i][j] = matches[0][0] + ' ' + matches[0][1] table[i][j] = transformer(j, table[i][j]) return table def main(table): return transpose(transform(table))" "response = [] temp = [] def transpose(table): for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_duplicate_columns(table): for row in table: del row[2] return table def transformer(i, value): if i == 0: replaced = value.replace('[at]', '@') return replaced if i == 1: x = 0 value.replace('+', '').replace('-', '') number = value[2:7] + ' ' + value[7:10] + value[10:13] + value[14:16] foo(value[value.find('#') + 1:]) return number if i == 2: name = value.replace('-', '/') return name def foo(val): i = 0 if val == 'Выполнено': temp.append('Y') elif val == 'Не выполнено': temp.append('N') def delete_empty_rows(table): return [row for row in table if row[0] is not None] def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) if i == 2: table.append(temp) delete_empty_rows(table) return table[0:4] def main(table): return transform(transpose(delete_duplicate_columns(table)))" "import re def main(table): for j in range(0, len(table)): num_del = table[j][0] table[j][0] = table[j][0].replace('+7', '+7(') num = table[j][0] table[j][0] = num[:6] + ')' + num[6:] num = table[j][0] table[j][0] = num[:10] + '-' + num[10:] num = table[j][0] table[j].remove(num_del) table[j][0] = num[:13] + '-' + num[13:] new_list = table[j][1].split('#') table[j][1] = table[j][1].split('#') table[j].remove(new_list) new_list[1] = new_list[1][:-2] new_list[0] = re.findall('@.{4,}', new_list[0]) new_list[0] = new_list[0][0] new_list[1] = new_list[1].replace(',', '') new_list[0] = new_list[0].replace('@', '') for elem in new_list: table[j].append(elem) return table" "def delete_duplicate_rows(table): new_table = [] end = len(table) flag = False for i in range(end): for j in range(len(new_table)): if table[i] == table[j]: flag = True if flag is False: new_table.append(table[i]) flag = False return new_table def transformer(j, value): if j == 0: return value + '00' if j == 1: replaced = value[2:7] + ' ' + value[7:13] + value[14:16] return replaced if j == 2: repl = value[8:10] + '.' + value[5:7] + '.' + value[2:4] return repl def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(delete_duplicate_rows(table))" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def transformer(i, value): if i == 0: replaced = value.replace('.', '-') return replaced if i == 1: digit_str = value.replace('%', '') digit = float(digit_str) / 100 return f'{digit:.1f}' if i == 2: replaced = value.replace(' ', '').replace('(', '').replace(')', '').replace('-', '') return replaced def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_empty_rows(table)))" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[1] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(-1) i.pop(-1) split = i[0].split(':') date = datetime.strptime(split[0], '%Y.%m.%d') i[0] = date.strftime('%y-%m-%d') i[1] = str(round(float(i[1]), 1)) i.append(split[1][:-5]) row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) new_table.append(row) return new_table" "def main(table): b = [] for i in table: if i not in b and i.count(None) != 5: tb = [] for j in i: if j: tb.append(j) tb[1] = tb[1].replace('0', 'Не выполнено').replace('1', 'Выполнено') tmp0 = tb[0].split(';') tb.insert(0, tmp0[0].split('-')[0]) tb[1] = tmp0[1].replace('@', '[at]') tb[3] = tb[3][:len(tb[3]) - 2].replace(',', '') b.append(tb) bf = [] for i in b: if i not in bf: bf.append(i) result = [] k = 0 for j in range(len(bf[0])): tmp = [] for i in range(len(bf)): tmp.append(bf[i][k]) k += 1 result.append(tmp) return result" "def main(table): a = [[str(round(float(i[0]), 1)), i[1].split(']')[1], 'Да' if int(i[1].split(';')[0]) else 'Нет', i[2].split()[1] + ' ' + i[2].split()[0]] for i in table] b = sorted(a, key=lambda x: x[3]) return b" "import re def rep(a, r=lambda a: [*filter(bool, a)]): a = r([r(x) for x in a]) no_seted = [*a] return [*sorted([*map(lambda x: x.split('~'), [*{*map(lambda x: '~'.join(x), a)}])], key=no_seted.index)] def main(a, r=re.search): a = rep(a) mail = [r('(?<=\\#)\\w+', a[i][0])[0] for i in range(len(a))] name = [r('\\w+', a[i][0])[0] + r('(?<=\\.)\\s\\w+', a[i][0])[0] for i in range(len(a))] date = [a[i][1][8:] + '.' + r('(?<=\\.)\\d{2}', a[i][1])[0] + '.' + r('\\d+', a[i][1])[0] for i in range(len(a))] return [[mail[i], name[i], date[i]] for i in range(len(name))]" "def main(nbook): n2 = [] for i in nbook: if i not in n2: n2.append(i) nbook = n2 for i in range(0, len(n2)): if n2[i][3] == 'true': n2[i][3] = 'Да' else: n2[i][3] = 'Нет' stroka = n2[i][1] stroka = stroka.replace('[at]', '@') n2[i][1] = stroka stroka = n2[i][2] stroka = stroka.split() n2[i][2] = stroka[1] stroka = str(n2[i][0]) stroka += '0' n2[i][0] = stroka return n2" "def delete_empty_rows(table): return [row for row in table if row[1] is not None] def delete_duplicate_columns(table): for row in table: del row[4] for row in table: del row[0] return table def transformer(i, value): if i == 0: replaced = value.replace('@', '[at]') return replaced[0:] if i == 1: digit_str = value.replace('%', '') digit = float(digit_str) / 100 return f'{digit:.2f}' if i == 2: name = value.split() return f'{name[0]}' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def sort(table): table.sort(key=sort_col) return table def sort_col(i): return i[2] def main(table): table1 = delete_empty_rows(table) table1 = delete_duplicate_columns(table1) table1 = transform(table1) table1 = sort(table1) return table1" "def main(a: list): for i in range(len(a)): cell = a[i][0].split(';') name = cell[1].split(', ') a[i][0] = name[1][:2] + ' ' + name[0] a[i][1] = 'да' if a[i][2] == 'true' else 'нет' a[i][2] = cell[0].replace('.', '-') return a" "def delete_empty_rows(table): return [row for row in table if row[1] is not None] def delete_empty_colomns(s): new = [] for i in s: cur = [] for j in i: if j is not None: cur.append(j) new.append(cur) return new def delete_duplicate_columns(table): for row in table: del row[3] return table def delete_duplicate_rows(s): new = [] for i in s: if i not in new: new.append(i) return new def splitting(s): new = [] for i in range(len(s)): cur = [] cur.append(s[i][0]) cur.append(s[i][1].split('!')[0]) cur.append(s[i][1].split('!')[1]) cur.append(s[i][2]) new.append(cur) return new def transformer(i, value): if i == 0: digit_str = float(value) * 100 digit = round(digit_str) return str(digit) + '%' if i == 1: replaced = value.replace('/', '-') return replaced[:6] + replaced[-2:] if i == 2: if value == 'false': return 'Не выполнено' elif value == 'true': return 'Выполнено' if i == 3: return value[value.find('@') + 1:] def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(splitting(delete_duplicate_columns(delete_duplicate_rows(delete_empty_colomns(delete_empty_rows(table))))))" "def column_1(s): ss = '' index = s.find('.') for i in range(0, index + 1): ss += s[i] return ss def column_2(ss): s = str(round(float(ss), 1)) return s def column_3(sss): ss = f'{sss[8] + sss[9]}.{sss[3] + sss[4]}.{sss[0] + sss[1]}' return ss def column_4(ssss): if ssss == 'true': return 'Выполнено' elif ssss == 'false': return 'Не выполнено' def main(lst): for i in range(len(lst)): for j in range(len(lst[0])): if j == 0: lst[i][j] = column_1(lst[i][j]) elif j == 1: lst[i][j] = column_2(lst[i][j]) elif j == 2: lst[i][j] = column_3(lst[i][j]) elif j == 3: lst[i][j] = column_4(lst[i][j]) return lst" "def del_row(s): s1 = [] for row in s: if row not in s1: s1.append(row) return s1 def transpose(s): s1 = [] for i in range(len(s[0])): s1.append([]) for j in range(len(s)): s1[i].append(s[j][i]) return s1 def main(s): s = [row for row in s if row[1] is not None] s = del_row(s) s = transpose(s) s = [row for row in s if row[0] is not None] s = transpose(s) for row in s: row[0] = row[0].replace('/', '-') b = row[1].split(';') row[1] = b[1] row.insert(2, b[0]) a = row[1].split('.') row[1] = a[0] + '.' + a[2] row[2] = row[2] + '00' s = transpose(s) return s" "def change_row(row): buff = row[0].split('-') buff = reversed(buff) buff = '/'.join(buff) row[0] = buff row[1] = 'Выполнено' if row[1] == 'да' else 'Не выполнено' name = row[2].split(':') num = name[1] name = name[0] name = name[name.find(' ') + 1:] num = num[num.find(')') + 1:] num = num[:-3] + num[-2:] row[2] = name row.append(num) return row def main(table): new = [] for row in table: if row[2] is None: continue if row in new: continue new.append(row) for i in range(len(new)): new[i] = change_row(new[i]) new = sorted(new, key=lambda x: x[3]) return new" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] row1 = [] row2 = [] row3 = [] for i in data: split = i[0].split('#') date = datetime.strptime(split[1], '%d-%m-%Y') i[0] = date.strftime('%y/%m/%d') i[1] = i[1][:12] + '-' + i[1][12:] if len(split[0]) == 2: split[0] = '0.0' + split[0][:-1] + '00' elif len(split[0]) == 4: split[0] = '1.0000' else: split[0] = '0.' + split[0][:-1] + '00' row1.append(i[0]) row2.append(i[1]) row3.append(split[0]) new_table.append(row1) new_table.append(row2) new_table.append(row3) return new_table" "import re def main(nbook): n2 = [] for i in nbook: if i not in n2 and i[0] is not None: n2.append(i) for i in n2: del i[2] del i[2] del i[2] for i in range(0, len(n2)): if n2[i][3] == 'Нет': n2[i][3] = 'false' else: n2[i][3] = 'true' stroka = n2[i][0] stroka = stroka.split('-') stroka = (stroka[-1], stroka[-2], stroka[-3]) stroka = str(stroka[0]) + '.' + str(stroka[1]) + '.' + str(stroka[2]) n2[i][0] = stroka stroka = n2[i][1] stroka = stroka.split(', ') stroka = stroka[1][0] + stroka[1][1] + ' ' + stroka[0] n2[i][1] = stroka stroka = re.findall('].*', n2[i][2]) stroka = stroka[0].replace(']', '') n2[i][2] = stroka nbook = [] for i in range(0, len(n2[0])): stroka = [] for j in range(len(n2)): stroka.append(n2[j][i]) nbook.append(stroka) return nbook" "def delete_duplicate_columns(table): for row in table: del row[2] return table def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_empty_columns(table): for row in table: del row[1] return table def delete_duplicate_rows(table): new_table = [] [new_table.append(x) for x in table if x not in new_table] return new_table def partition(table): for i in range(len(table)): startt = str(table[i][1]).find('&') + 1 status = str(table[i][1])[startt:len(str(table[i][1]))] fio = str(table[i][1])[0:2] + ' ' + str(table[i][1])[5:startt - 1] table[i].pop() if status == 'true': table[i].append('да') else: table[i].append('нет') table[i].append(fio) return table def transform(table): for i in range(len(table)): startt = str(table[i][0]).find('&') num = '{:.4f}'.format(float(str(table[i][0])[0:startt]) / 100) table[i][0] = num return table def transposition(table): new_table = [] for j in range(3): new_row = [] for i in range(len(table)): new_row.append(table[i][j]) new_table.append(new_row) return new_table def main(table): return transposition(transform(delete_duplicate_rows(partition(delete_empty_columns(delete_empty_rows(delete_duplicate_columns(table)))))))" "def myReversed(value): temp = value.split('.') res = '' for i in range(len(temp)): res += ''.join(reversed(temp[i])) + '-' return res[:-1] def swap(table): for i in range(len(table)): (table[i][1], table[i][2]) = (table[i][2], table[i][1]) return table def split_by_sep(table): for row in table: if row[0] is not None: temp = row[0].split('!') row[0] = temp[0] row[1] = temp[1] return table def delete_empty(table): temp = [] k = 0 for i in range(len(table)): for j in range(len(table[0])): if table[i][j] == '': table[i][j] = None if table[i][j] is not None: if j == 0: k += 1 temp.append([]) temp[k - 1].append(table[i][j]) return temp def delete_duplicate_row(table): j = 0 for i in range(len(table)): j = i + 1 while j < len(table): if table[i] == table[j]: del table[j] j -= 1 j += 1 return table def transformer(i, value): if i == 0: res = myReversed(value) res = ''.join(reversed(res)) return res if i == 1: digit_str = value.replace('+7 ', '') return digit_str if i == 2: if value == 'N': return '0' if value == 'Y': return '1' if i == 3: x = float(value) x = str(round(x, 2)) if len(x) == 3: x = x + '0' return x def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): split_by_sep(table) x = delete_empty(table) x = transform(x) x = delete_duplicate_row(x) x = delete_empty(x) x = swap(x) return x" "from datetime import datetime import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(2) i.pop(1) i[0] = re.sub('.*\\[at\\]', '', i[0]) split = i[1].split(';') date = datetime.strptime(split[0], '%y/%m/%d') i[1] = date.strftime('%d/%m/%y') if len(split[1]) == 4: split[1] = '100%' elif len(split[1]) == 2: split[1] = '0.0' + split[1][:-1] + '0' else: split[1] = '0.' + split[1][:-1] + '0' i.append(split[1]) row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) new_table.append(row) return new_table" "def main(table): table = first(table) table = second(table) table = third(table) table = fourth(table) table = fifth(table) return table def first(table): return [row[0:3] for row in table] def second(table): return [row[1:3] for row in table] def third(table): new_table = [] for row in table: if row not in new_table: new_table.append(row) return new_table def fourth(table): for row in table: row.append(row[0].split('#')[1]) row[0] = row[0].split('#')[0] return table def fifth(table): for row in table: row[0] = '.'.join(row[0].split('.')[::-1]) row[1] = row[1].split(' ') row[1] = row[1][-1] + ', ' + row[1][0][0] + '.' + row[1][1] row[2] = 'Да' if row[2] == 'true' else 'Нет' return table" "def main(nbook): n2 = [] for i in nbook: if i not in n2 and i[0] is not None: n2.append(i) for i in range(0, len(n2)): if n2[i][0] == '0': n2[i][0] = 'Нет' else: n2[i][0] = 'Да' n2[i][1] = n2[i][1].replace('@', '[at]') n2[i][2] = str(round(float(n2[i][2]), 1)) stroka = n2[i][3] new_strk = '' new_strk += stroka[-8] + stroka[-7] + stroka[-6] new_strk += stroka[-5] + stroka[-4] + stroka[-3] new_strk += '-' + stroka[-2] + stroka[-1] n2[i][3] = new_strk nbook = [] for i in range(0, len(n2[0])): stroka = [] for j in range(len(n2)): stroka.append(n2[j][i]) nbook.append(stroka) return nbook" "import re def main(table): try: for j in range(0, len(table)): if table[j][0] is None: table.remove(table[j]) table_del = table[j][0] table[j][0] = re.findall('.{1,}@', table[j][0]) table[j][0] = table[j][0][0] table[j][0] = table[j][0].replace('@', '') table[j].remove(table_del) stolb3 = table[j][1] table[j][1] = re.findall('.{1,}#', table[j][1]) table[j][1][0] = table[j][1][0].replace('#', '') table[j][1][0] = round(float(table[j][1][0]), 2) table[j][1] = str(table[j][1][0]) if len(table[j][1]) == 3: table[j][1] = table[j][1] + '0' table[j].append('1') table[j][2] = re.findall('#.{1,}', stolb3) table[j][2] = table[j][2][0] table[j][2] = table[j][2].replace('#', '') table[j][2] = table[j][2][:1] + '.' + table[j][2][0:] hz_dava = re.findall('.\\.', table[j][2]) hz_tri = re.findall('\\. .{1,}', table[j][2]) hz_tri = hz_tri[0].replace('. ', '') table[j][2] = hz_dava[0] + hz_dava[1] + ' ' + hz_tri except IndexError: pass return table" "import re def main(table): try: for j in range(len(table)): if table[j][1] is None: table.remove(table[j]) if table[j][0] is None: table[j].remove(None) rab_str = table[j][0] table[j][0] = re.findall('@.{1,}', table[j][0]) table[j][0] = table[j][0][0] table[j][0] = table[j][0].replace('@', '') if len(table[j][1]) == 4: table[j][1] = table[j][1] + '0' number = table[j][1] table[j].remove(table[j][1]) rab_str = re.findall('.{1,},', rab_str) rab_str = rab_str[0] rab_str = rab_str.replace(',', '') table[j].append(rab_str) table[j].append(number) except IndexError: pass return proverka(table) def proverka(table): table.reverse() for i in table: if table.count(i) > 1: while table.count(i) != 1: table.remove(i) table.reverse() return table" "import re def main(table): try: for j in range(len(table)): if table[j][0] is None: table[j].remove(None) table[j].remove(None) rab_str = table[j][0] hz = re.findall('#.{1,}', table[j][0]) table[j][0] = hz[0] table[j][0] = table[j][0].replace('#', '') table[j][0] = table[j][0] + '000' table[j][1] = table[j][1].capitalize() rab_str = rab_str.replace('(', '') rab_str = rab_str.replace(') ', '') rab_str = rab_str.replace('-', '') rab_str = re.findall('.{1,}#', rab_str) rab_str = rab_str[0] rab_str = rab_str.replace('#', '') table[j].append(rab_str) except IndexError: pass return proverka(table) def proverka(table): table.reverse() for i in table: if table.count(i) > 1: while table.count(i) != 1: table.remove(i) table.reverse() return table" "def main(x): for i in x: for j in i: if i.count(j) > 1: i.remove(j) yes = i[0][i[0].find('|') + 1:] tel = i[0][:i[0].find('|')] i[0] = yes i.append(tel) if i[0] == 'Нет': i[0] = 'Не выполнено' if i[0] == 'Да': i[0] = 'Выполнено' i[1] = str(round(float(i[1]), 1)) i[2] = i[2][5:] left = i[2][:3] right = i[2][3:] i[2] = left + '-' + right y = [] templist0 = [] templist1 = [] templist2 = [] for i in x: templist2.append(i[2]) templist1.append(i[1]) templist0.append(i[0]) y.append(templist0) y.append(templist1) y.append(templist2) return y" "def main(tabl): parsed = set() result = [] for (name, num, email) in tabl: parsed_res = [] if name is None: continue name_list = name.split(' ') name_tmp = name_list[1] name_list[1] = name_list[0] name_list[0] = name_tmp parsed_res.append(' '.join(name_list)) parsed_res.append(str(format(float(num), '.4f'))) parsed_res.append(email.replace('[at]', '@')) if parsed_res not in result: result.append(parsed_res) return [[result[j][i] for j in range(len(result))] for i in range(len(result[0]))]" "def main(table): new_table = list() for row in table: if set(row) != {None}: new_table.append(row) new_table2 = list(map(list, zip(*new_table))) new_table3 = list() for row in new_table2: if row not in new_table3 and set(row) != {None}: new_table3.append(row) new_table4 = list(map(list, zip(*new_table3))) for row in new_table4: if row[0] == 'Не выполнено': row[0] = 'false' if row[0] == 'Выполнено': row[0] = 'true' date = row[3].split('.') row[3] = '-'.join(date[::-1]) row[2] = row[2].replace('[at]', '@') row[1] = str(round(float(row[1]), 3)).ljust(5, '0') new_table4.sort(key=lambda x: x[2]) return new_table4" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] sort_table = [] row1 = [] row2 = [] row3 = [] for i in data: i.pop(-1) split = i[1].split(';') if len(i[0]) == 2: i[0] = '0.0' + i[0][:-1] + '0' elif len(i[0]) == 4: i[0] = '1.000' else: i[0] = '0.' + i[0][:-1] + '0' date = datetime.strptime(split[0], '%Y.%m.%d') i[1] = date.strftime('%d-%m-%y') i.append(split[1][:2] + ' ' + split[1][5:]) row = [] row.append(i[2]) row.append(i[1]) row.append(i[0]) sort_table.append(row) sort_table.sort() for i in sort_table: row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) new_table.append(row3) new_table.append(row2) new_table.append(row1) return new_table" "def parse_result(result): (a, b, c, d) = ([], [], [], []) for arr in result: a.append(arr[0]) b.append(arr[1]) c.append(arr[2]) d.append(arr[3]) return [a, b, c, d] def main(table): parsed = set() result = [] for (percent, _, _, data, phone, _) in table: (score, fullname, phone_p, email) = ([], [], [], []) if data in parsed or data is None: continue parsed.add(data) score.append(f""{float(percent.strip('%')) / 100:.3f}"") data_p = data.split('&') fullname.append(f'{data_p[1].split()[1]} {data_p[1].split()[0]}') p_phone = phone.split(' ') phone_p.append(f""({p_phone[1]}) {p_phone[2].split('-')[0]}-{p_phone[2].split('-')[1]}{p_phone[2].split('-')[2]}"") email.append(f""{data_p[0].split('@')[0]}"") result.append([score[0], fullname[0], phone_p[0], email[0]]) result = sorted(result, key=lambda x: x[3]) return parse_result(result)" "def main(values): Valve = [] for i in values: if i[0] is not None: name = i[0].partition('.')[0] name2 = i[0].partition('.')[2] name2 = name2.partition('.')[2] name = name + '.' + name2 pochta = i[3].partition(']')[2] number = str(round(float(i[4]), 2)) if len(number) < 4: number += '0' Valve.append([name, pochta, number]) return Valve" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0]] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(3) i[0] = i[0].replace('@', '[at]') split = i[1].split(' ') i[1] = split[1] i[2] = i[2][:2] + '(' + i[2][3:6] + ')' + i[2][7:13] + '-' + i[2][13:] date = datetime.strptime(i[3], '%Y-%m-%d') i[3] = date.strftime('%y.%m.%d') row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) row.append(i[3]) new_table.append(row) return new_table" "def main(values): Valve = [] for i in values: if i[0] is not None: name = str(i[2]).partition('|')[0] name1 = name.partition(' ')[2] name = name1 + ' ' + name.partition(' ')[0] flag = True for j in Valve: if j[2] == name: flag = False if flag: bulka = 'да' if i[0] == 'N': bulka = 'нет' data = str(i[2]).partition('|')[2] data1 = data.partition('/')[0] data2 = data.partition('/')[2] data3 = data2.partition('/')[2] data2 = data2.partition('/')[0] data3 = data3[2] + data3[3] data = data3 + '/' + data2 + '/' + data1 pochta = str(i[3]).partition(']')[2] Valve.append([bulka, data, name, pochta]) return Valve" "import re def main(s): new_list = [] for i in range(len(s)): new_list.append([]) for j in range(len(s[0])): if s[i][j] not in new_list[i]: new_list[i].append(s[i][j]) for i in range(len(new_list)): new_list[i][0] = new_list[i][0].replace('-20', '/') new_list[i][0] = new_list[i][0].replace('-19', '/') new_list[i][0] = new_list[i][0].replace('-', '/') string = new_list[i][1].split('!') if string[0] == 'нет': new_list[i][1] = 'Не выполнено' else: new_list[i][1] = 'Выполнено' string = string[1] regex = '\\S+' match = re.findall(regex, string) new_list[i].append(match[0]) return new_list" "def main(x): (x1, x2, x3, x4) = ([], [], [], []) for i in range(0, len(x)): if x[i][0] == 'нет': x1.append('false') else: x1.append('true') x2.append(x[i][1].replace('/', '-')) if x[i][2] == '1.0': x3.append('1.00') else: x3.append(x[i][2] + '0') x4.append(preb(x[i])) return [x1, x2, x3, x4] def preb(x): return x[3][x[3].find(' ') + 1:] + ' ' + x[3][:x[3].find('.') + 1]" "import re def main(table): for j in range(0, len(table)): if table[j][0] == 'true': table[j][0] = table[j][0].replace('true', 'Да') else: table[j][0] = table[j][0].replace('false', 'Нет') table[j][1] = table[j][1].replace('@', '[at]') if table[j][2] == '100%': table[j][2] = '1.00' elif len(table[j][2]) == 2: table[j][2] = '0.0' + table[j][2] table[j][2] = table[j][2].replace('%', '') else: table[j][2] = table[j][2].replace('%', '') table[j][2] = '0.' + table[j][2] table[j][3] = table[j][3][:1] + '.' + table[j][3] rab_str = table[j][3] rab_str = re.findall('.\\.', rab_str) rab_str = rab_str[0] + rab_str[1] table[j][3] = re.findall('\\. .{1,}', table[j][3]) table[j][3] = table[j][3][0] table[j][3] = table[j][3].replace('.', '') table[j][3] = rab_str + table[j][3] return proverka(table) def proverka(table): table.reverse() for i in table: if table.count(i) != 1: while table.count(i) != 1: table.remove(i) table.reverse() return table" "def main(matrix): new_matrix = [] for i in range(len(matrix)): new_massive = [] line = matrix[i][1].split(':') new_massive.append(line[1][:3] + '-' + line[1][3:6] + '-' + line[1][6:]) line_two = matrix[i][2].split(' ') new_massive.append(line_two[0] + ' ' + line_two[2]) line_three = line[0].replace('@', '[at]') new_massive.append(line_three) line_four = matrix[i][3] new_massive.append(str(int(float(line_four) * 100)) + '%') if not new_massive in new_matrix: new_matrix.append(new_massive) return new_matrix" "def remove_empty_columns(table): for i in range(len(table)): for j in range(len(table[0])): for k in range(table[i].count(None)): table[i].remove(None) return table def remove_double_rows(table): new_table = list() for row in table: if row not in new_table and set(row) != {None}: new_table.append(row) return new_table def transform(new_table): for i in range(len(new_table)): for j in range(len(new_table[0])): if j == 0: new_table[i][j] = new_table[i][j].replace('.', '-') if j == 1: new_table[i][j] = new_table[i][j].replace('да', 'Да') new_table[i][j] = new_table[i][j].replace('нет', 'Нет') if j == 2: new_table[i][j] = new_table[i][j][:new_table[i][j].index('@')] return new_table def main(table): return transform(remove_double_rows(remove_empty_columns(table)))" "def duplicateCols(table): for x in table: del x[4] return table def emptyCols(table): for x in table: del x[3] return table def divide(table): for x in table: x.append(x[0][:x[0].find('!')]) x[0] = x[0][x[0].find('!') + 1:] return table def var(table): for x in table: x[0] = x[0][:x[0].find('@')] + '[at]' + x[0][x[0].find('@') + 1:] if x[1] == 'Y': x[1] = 'true' else: x[1] = 'false' (x[2], x[3]) = (x[3], x[2]) x[2] = x[2][x[2].find('.') + 2:] + ' ' + x[2][:x[2].find(' ')] x[3] = '(' + x[3][3:6] + ')' + x[3][6:] return table def sortBy4Col(x): for i in range(len(x) - 1): for j in range(len(x) - 1 - i): if int(x[j][3][1:4]) > int(x[j + 1][3][1:4]): (x[j], x[j + 1]) = (x[j + 1], x[j]) return x def trans(table): trans = [] for i in range(4): trans.append([]) for j in range(len(table)): trans[i].append(table[j][i]) return trans def main(table): return trans(sortBy4Col(var(divide(emptyCols(duplicateCols(table))))))" "def change_list(any_list): any_list[0] = any_list[0].replace('%', '') any_list[0] = '{:.4f}'.format(float(any_list[0]) / 100) any_list[1] = any_list[1][any_list[1].index(' ') + 1:] any_list[2] = any_list[2][any_list[2].index('.') + 2:] + ', ' + any_list[2][0] + '.' + any_list[2][any_list[2].index('.') - 1] + '.' any_list[3] = any_list[3].replace('[at]', '@') return any_list def main(old_list): list_without_repetitions = [] for el in old_list: if el not in list_without_repetitions: list_without_repetitions.append(el) for i in range(len(list_without_repetitions)): list_without_repetitions[i][3] = None list_without_repetitions[i] = list(filter(None, list_without_repetitions[i])) list_without_repetitions = list(filter(None, list_without_repetitions)) for i in range(len(list_without_repetitions)): list_without_repetitions[i] = change_list(list_without_repetitions[i]) return list_without_repetitions" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def transformer(i, value): if i == 0: name = value.split('@') return f'{name[1]}' if i == 1: return 'да' if value == 'Да' else 'нет' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def tr(table): response = [] q = [] for i in range(3): response.append([]) if i == 0: for j in range(len(table[0])): q.append(table[i][j].split('|')) for j in range(len(q)): response[i].append(q[j][0]) if i == 1: for j in range(len(q)): response[i].append(q[j][1] + '0') if i == 2: for j in range(len(q)): response[i].append(table[1][j]) return response def main(table): return tr(transform(transpose(table)))" "def del_empty_lines(table): return [row for row in table if row[1] is not None] def transpose(table): new_list = [] for i in range(len(table[0])): temp_line = [] for j in range(len(table)): temp_line.append(table[j][i]) new_list.append(temp_line) return new_list def del_duplicate_columns(table): new_list = [] for item in table: if item not in new_list: new_list.append(item) return new_list def refactor_names_dates(table): for i in range(len(table)): name = table[i][0].split(',') table[i][0] = f""{name[0]} {name[1].split('.')[0].strip()}."" date = table[i][-1].split('-') table[i][-1] = f'{date[2][-2:]}-{date[1]}-{date[0]}' table[i][1] = table[i][1].capitalize() return table def main(table): return transpose(refactor_names_dates(del_duplicate_columns(transpose(del_duplicate_columns(del_empty_lines(transpose(del_empty_lines(table))))))))" "def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): return table def transformer(i, value): if i == 0: replaced = value.replace(' ', '').replace('-', '') return replaced if i == 1: return '0' if value == 'нет' else '1' if i == 2: name = value.split() return f'{name[2]}' if i == 3: replaced = value.replace('-', '') return replaced[4:] def transform1(table): for i in reversed(range(len(table))): f = 0 buf = table[i][0] for k in range(len(table)): if buf == table[k][0]: f += 1 if f == 2: for j in range(len(table[i])): table[i][j] = None return table def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return delete_empty_rows(transform1(transform(delete_empty_rows(table))))" "def doubleCols(table): for x in table: del x[3] return table def separate(table): for x in table: x.append(x[1][x[1].find(':') + 1:] + '0') x[1] = x[1][:x[1].find(':')] (x[2], x[3]) = (x[3], x[2]) return table def changes(table): for x in table: x[1] = x[1][:x[1].find('[')] + '@' + x[1][x[1].find(']') + 1:] x[0] = x[0][:3] + '-' + x[0][3:] x[3] = x[3][:2] + '.' + x[3][3:5] + '.' + x[3][6:] return table def main(table): return changes(separate(doubleCols(table)))" "def delDuplicate(table): temp_table = [] for a in table: if a not in temp_table: temp_table.append(a) return temp_table def main(table): result_table = [] def insert(temp): if len(temp[0]) != 0 and len(temp[1]) == 0: result_table.insert(1, temp[0]) elif len(temp[0]) != 0 and len(temp[1]) != 0: result_table.insert(0, temp[0]) result_table.insert(2, temp[1]) table = delDuplicate(table) for a in range(len(table[0])): temp = [[], []] for b in range(len(table)): if table[b][a] is None: continue if a == 0: tables = table[b][a].split('|') if bool(int(tables[0])): temp[0].append('Выполнено') else: temp[0].append('Не выполнено') temp[1].append(tables[1][:-2]) if a == 3: temp[0].append(str(round(float(table[b][a]), 2)).ljust(4, '0')) insert(temp) return result_table" "def first(s): new = [] for i in s: cur = [] for j in i: if j not in cur: cur.append(j) new.append(cur) return new def second(s): new = [] for i in s: cur = [] for j in i: if j is not None: cur.append(j) new.append(cur) return new def third(s): for i in s: i[0] = i[0].split('-')[0] i[1] = i[1].split('[at]')[1] i[2] = i[2].split(' ')[1] + ' ' + i[2].split(' ')[0] if i[3] == '1': i[3] = 'true' elif i[3] == '0': i[3] = 'false' return s def main(s): return third(second(first(s)))" "def first(s): new = [] for i in s: cur = [] for j in i: if j not in cur: cur.append(j) new.append(cur) return new def second(s): new = [] for i in s: cur = [] for j in i: if j is not None: cur.append(j) if len(cur) != 0: new.append(cur) return new def third(s): for i in s: i[0] = i[0] + '0' if i[1] == 'N': i[1] = 'Нет' elif i[1] == 'Y': i[1] = 'Да' i[2] = i[2][2:7] + ' ' + i[2][7:11] + i[2][11:13] + i[2][14:] return s def fourth(s): new = [] count = [] y_n = [] number = [] for i in s: count.append(i[0]) y_n.append(i[1]) number.append(i[2]) new.append(count) new.append(y_n) new.append(number) return new def main(s): return fourth(third(second(first(s))))" "def main(lst): for i in lst: for p in i[:]: if p is None: i.remove(p) else: continue tmp = [] for i in lst: if i in tmp: continue else: tmp.append(i) result = [] for element in tmp: mail = element[0] name = element[2] name1 = element[2] date = element[3] mail = mail[:mail.find('[')] name = name[name.rfind(' ') + 1:] + ', ' + name[0] + '.' name += name1[name1.find(' ') + 1:name1.find(' ') + 3] date = date.replace('/', '-') date = date[6:] + date[2:6] + date[:2] tmp1 = [] tmp1.append(mail) tmp1.append(name) tmp1.append(date) result.append(tmp1) return result" "def separate(table): for x in table: x.append(x[0][:6] + x[0][8:x[0].find('#')]) x[0] = x[0][x[0].find('#') + 1:] return table def change(table): for x in table: x[0] = x[0][:x[0].find('@')] + '[at]' + x[0][x[0].find('@') + 1:] if x[1] == '0': x[1] = 'N' else: x[1] = 'Y' return table def main(table): return change(separate(table))" "def main(a): k = 0 b = list(map(list, zip(*a))) b = [i for i in b if i[0] is not None] if b[0]: for i in b[0]: s = i.split() b[0][k] = s[1] k += 1 if b[1]: k = 0 for i in b[1]: b[1][k] = i.replace('-', '') k += 1 if b[2]: k = 0 for i in b[2]: b[2][k] = str(int(float(i) * 100)) + '%' k += 1 return b" "def main(nbook): n2 = [] for i in nbook: if i not in n2 and i[0] is not None: n2.append(i) n3 = [] for i in range(0, len(n2)): if n2[i][2] == 'Нет': n2[i][2] = 'нет' else: n2[i][2] = 'да' stroka = n2[i][0] stroka = stroka.split('[at]') stroka = stroka[0] n2[i][0] = stroka stroka = n2[i][1] stroka = stroka.split('!') stroka0 = stroka[0] stroka = stroka[1] stroka = stroka.replace('%', '') if len(stroka) == 1: stroka = '0' + stroka n2[i][1] = '0.' + stroka elif len(stroka) == 3: n2[i][1] = '1.00' else: n2[i][1] = '0.' + stroka stroka0 = stroka0.replace('+7', '') stroka0 = stroka0.replace(' ', '') stroka0 = stroka0.replace('-', '') n3.append([n2[i][0], stroka0, n2[i][1], n2[i][2]]) nbook = [] for i in range(0, len(n3[0])): stroka = [] for j in range(len(n3)): stroka.append(n3[j][i]) nbook.append(stroka) return nbook" "def main(table): parsed = set() (flag, fullname, score_r) = ([], [], []) for (_, data, score) in table: if data in parsed or data is None: continue parsed.add(data) data_p = data.split('&') flag.append('true' if data_p[1] == '1' else 'false') fullname.append(f'{data_p[0].split()[1]} {data_p[0].split()[0]}') score_r.append(f'{float(score):.2f}') return [flag, fullname, score_r]" "import re def delete_empty_rows(table): return [row for row in table if row[1] is not None] def delete_empty_columns(table): for raw in table: del raw[2] return table def delete_duplicate_raws(table): j = 0 for raw in table: raw1 = raw[1] i = 0 for raw in table: if raw[1] == raw1 and j != i: k = j i += 1 j += 1 del table[k] return table def replace_number(table): for raw in table: raw[0] = re.sub('.+#', '', raw[1]) raw[1] = re.sub('#[^\\n]*', '', raw[1]) return table def transformer(i, value): if i == 0: clear = value.replace('(', '') clear = clear.replace(')', '') clear = clear.replace('#', '') return clear if i == 1: out = re.sub('\\s\\w\\W', '', value) return out if i == 2: mail = re.sub('.+]', '', value) return mail def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(replace_number(delete_duplicate_raws(delete_empty_columns(delete_empty_rows(table)))))" "def main(table): for row in table: del row[1] del row[2] for row in table: (flag, numm) = row[0].split('!') row.insert(0, 'Да' if flag == 'Выполнено' else 'Нет') row[1] = row[2].replace('-', '.') row[2] = str(int(float(numm) * 100)) + '%' row[3] = row[3].replace(' ', '').replace('-', '') i = 0 j = 0 for row in table: for j in range(i): if int(table[i][3]) < int(table[j][3]): (table[j], table[i]) = (table[i], table[j]) j += 1 i += 1 for row in table: (row[1], row[2], row[3]) = (row[1], row[2], row[3]) table = list(map(list, zip(*table))) return table" "def f(lul): n = [] for i in lul: if i not in n and i[0] is not None: n.append(i) return n def trans(matrix): trans_matrix = [[0 for j in range(len(matrix))] for i in range(len(matrix[0]))] for i in range(len(matrix)): for j in range(len(matrix[0])): trans_matrix[j][i] = matrix[i][j] return trans_matrix def main(matrix): matrix = f(matrix) trans_matrix = trans(matrix) trans_matrix = f(trans_matrix) matrix = trans(trans_matrix) for i in range(len(matrix)): matrix[i][0] = matrix[i][0].split(' ') matrix[i][0] = matrix[i][0][2] + ' ' + matrix[i][0][0][0] + '.' + matrix[i][0][1] matrix[i][1] = matrix[i][1].replace('\n', '') matrix[i][1] = matrix[i][1].replace('-', '/') matrix[i][2] = matrix[i][2][3:6] + matrix[i][2][7:10] + matrix[i][2][-4:] return matrix" "import re from itertools import groupby import itertools def unique_items(x): found = set() for item in x: if len(item) > 0: if item[0] not in found: yield item found.add(item[0]) def main(x): for i in range(0, len(x)): x[i] = [k for k in x[i] if k] x = list(unique_items(x)) x = [i for i in x if i] transpoted_x = list(map(list, itertools.zip_longest(*x, fillvalue=None))) transpoted_x = [i for (i, _) in groupby(transpoted_x)] true_x = [] for i in range(0, len(x)): massiv = [] nomer = re.split(';', transpoted_x[0][i])[1] nomer_1 = re.sub('\\+7 \\([0-9]{3}\\) ', '', nomer) data = re.split(';', transpoted_x[0][i])[0] data_1 = re.findall('\\d{4}', data)[0] data_1 = data_1[2:] data = re.sub('\\d{4}', data_1, data) data = re.split('\\.', data) data = f'{data[2]}-{data[1]}-{data[0]}' number = str(round(float(transpoted_x[1][i]) * 100)) + '%' names = re.split(' ', transpoted_x[2][i]) names = f'{names[2]} {names[0][0]}.{names[1]}' massiv.append(nomer_1) massiv.append(data) massiv.append(number) massiv.append(names) true_x.append(massiv) true_x = sorted(true_x, key=lambda row: row[1]) true_x = list(map(list, itertools.zip_longest(*true_x, fillvalue=None))) return true_x" "def main(array): counter = -1 for i in array: counter += 1 if i[0] is None and i[1] is None and (i[2] is None): array.pop(counter) farray = [] for i in array: if i not in farray: farray.append(i) array = farray for i in range(len(array)): array[i][1] = array[i][2].replace('+7', '') array[i][0] = array[i][0].replace('%', '') array[i][2] = None array[i] = list(filter(None, array[i])) array[i][0] = str(round(int(array[i][0]) / 100, 1)) if array[i][2] == 'true': array[i][2] = 'да' else: array[i][2] = 'нет' array[i][1] = '(' + array[i][1][0:3] + ') ' + array[i][1][3:6] + '-' + array[i][1][6:8] + '-' + array[i][1][8:10] array.sort(key=lambda x: x[1]) return array" "def main(_list): non = [None, None, None] while non in _list: _list.remove(non) for line in _list: line[0] = line[0].replace('[at]', '@') line[1] = line[2][:line[2].find(' ')] line[2] = line[2][line[2].find('!') + 1:] line[2] = line[2].replace('нет', 'N') line[2] = line[2].replace('да', 'Y') for line in _list: counter = 0 for i in range(len(_list)): if line[0] == _list[i][0]: counter += 1 if counter > 1: _list.reverse() _list.remove(line) _list.reverse() return _list" "def del_dup(list): dup_free = [] for i in range(len(list)): if list[i] not in dup_free: dup_free.append(list[i]) return dup_free def delete_empty_rows(table): return [row for row in table if row[0] is not None] def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def rev(num: str): return num[6:8] + num[2:6] + num[0:2] def transformer(i, value): if i == 0: return rev(value) if i == 1: return value if i == 2: return value[:-2].replace(',', '') def main(table): dup_free = [] table = list(filter(any, table)) for i in range(len(table)): if table[i] not in dup_free: dup_free.append(table[i]) table = dup_free table = filter(None, table) table = (row[0].split('|') + [row[1].replace('@', '[at]')] for row in table) table = ([row[1], row[2], row[0]] for row in table) table = [list(row) for row in zip(*table)] return transform(table)" "def delete_duplicate_columns(table): for row in table: del row[2] return table def func(table): while True: flag = 0 for i in range(len(table[0])): count = 1 if table[0][i] is None: for j in range(1, len(table)): if table[j][i] is None: count += 1 if count == len(table): for k in range(len(table)): table[k].pop(i) flag = 1 break if flag == 1: break if flag == 0: break return table def main(table): table = delete_duplicate_columns(table) for i in range(len(table)): for j in range(i + 1, len(table)): if table[j] == table[i] and table[j] != [None, None, None, None]: table[j] = [None, None, None, None] while table.count([None, None, None, None]): table.pop(table.index([None, None, None, None])) table = func(table) for i in range(len(table)): table[i][0] = str(table[i][0])[6:8] + '/' + str(table[i][0])[3:5] + '/' + str(table[i][0])[0:2] table[i][1] = str(table[i][1])[9:12] + str(table[i][1])[13:15] + str(table[i][1])[16:18] if table[i][2] == 'Да': table[i][2] = 'Выполнено' else: table[i][2] = 'Не выполнено' return table" "import re def delete_empty_rows(table): return [row for row in table if row[0] is not None] def del_dup_rows(table): for row1 in range(0, len(table) - 1): for row2 in range(row1 + 1, len(table)): if table[row1] == table[row2]: del table[row2] return del_dup_rows(table) return table def round_colum(table): for row in range(0, len(table)): n = round(float(table[row][1]), 1) table[row][1] = str(n) return table def split_cell(table): for row in range(0, len(table)): table[row].append(table[row][1]) a = table[row][0].split(';') table[row][0] = a[0] table[row][1] = a[1] return table def ref_cell(table): for row in range(0, len(table)): c = re.findall('\\w*\\S[.]\\w*', table[row][0]) table[row][0] = c[0] b = re.findall('\\d{2}', table[row][1]) table[row][1] = b[2] + '-' + b[1] + '-' + b[0] return table def main(table): return ref_cell(split_cell(round_colum(delete_empty_rows(del_dup_rows(table)))))" "def delete_empty_cr(table): new_table = [] for i in table: list = [x for x in i if x is not None] if list: new_table.append(list) return new_table def split_column(table): new_table = [] for i in table: list = [] for j in range(0, len(i), 1): if j == 2: list.append(str(i[j]).split(';')[0]) list.append(str(i[j]).split(';')[1]) else: list.append(i[j]) new_table.append(list) return new_table def trans_data(table): new_table = [] for i in table: list = [] for j in range(0, len(i), 1): if j == 0: st = i[j] if st == 'нет': list.append('Не выполнено') else: list.append('Выполнено') if j == 1: st = str(i[j]).replace('(', '').replace(')', '')[0:8] st += str(i[j])[10:15].replace('-', '') list.append(st) if j == 2: st = str(i[j].replace('/', '.'))[6:8] + '.' st += str(i[j].replace('/', '.'))[3:5] + '.' st += str(i[j].replace('/', '.'))[0:2] list.append(st) if j == 3: list.append(str(i[j]).replace('[at]', '@')) new_table.append(list) return new_table def transp_matrix(table): new_table = [] list_1 = [] list_2 = [] list_3 = [] list_4 = [] for i in table: for j in range(0, len(i), 1): if j == 0: list_1.append(i[j]) if j == 1: list_2.append(i[j]) if j == 2: list_3.append(i[j]) if j == 3: list_4.append(i[j]) new_table.append(list_1) new_table.append(list_2) new_table.append(list_4) new_table.append(list_3) return new_table def main(h): return transp_matrix(trans_data(split_column(delete_empty_cr(h))))" "def main(table): for i in range(len(table)): table[i][0] = table[i][0][7:] table[i][1] += '0' table[i][2] = '%s.%s.%s' % (table[i][2][8:], table[i][2][5:7], table[i][2][2:4]) table[i][3] = table[i][3].replace('@', '[at]') table.sort() return table" "def change_row(row): row.pop(0) row.pop(0) row[0] = row[0][row[0].find('@') + 1:] num = row[1].split('#') tf = num[1] num = num[0] tf = 'да' if tf == 'true' else 'нет' num = num.replace(' ', '-') row[1] = tf row.append(num) return row def main(table): new = [] for row in table: if row in new: continue new.append(row) for i in range(len(new)): new[i] = change_row(new[i]) new.sort(key=lambda x: x[2]) new_table = [[None for _ in range(len(new))] for _ in range(len(new[0]))] for (i, row) in enumerate(new): for (j, cell) in enumerate(row): new_table[j][i] = cell return new_table" "def main(data): res = [] for i in range(len(data)): if data[i][1:] not in res and data[i] != [None, None, None, None]: res.append(data[i][1:]) for ml in res: x = ml[0].split(' ') ml[0] = f'{x[0]} {x[2]}' ml[1] = ml[1].replace('@', '[at]') d = '.'.join([x for x in reversed(ml[2].split('|')[0].split('/'))]) p = f""{int(float(ml[2].split('|')[1]) * 100)}%"" ml.append(d) ml.append(p) ml.pop(2) return res" "def del_row(s): s1 = [] for row in s: if row not in s1: s1.append(row) return s1 def transpose(s): s1 = [] for i in range(len(s[0])): s1.append([]) for j in range(len(s)): s1[i].append(s[j][i]) return s1 def main(s): s = [row for row in s if row[0] is not None] s = del_row(s) for row in s: row[1] = row[1][5:8] + '-' + row[1][8:] for row in s: buff = row[0].split('!') b = buff[0] row[0] = b.split('/')[2] + '/' + b.split('/')[1] + '/' + b.split('/')[0] if buff[1] == 'true': buff[1] = 'Выполнено' else: buff[1] = 'Не выполнено' row.insert(1, buff[1]) s.sort(key=lambda x: x[2], reverse=False) return s" "def main(_list): for i in _list: if _list.count(i) > 1: _list.remove(i) for line in _list: while None in line: line.remove(None) n = line[0][line[0].find('. ') + 2:] + ', ' s = line[0][:1] + '.' e = line[0][line[0].find(' ') + 1:line[0].find('.') + 1] line[0] = n + s + e line[1] = line[1][0].upper() + line[1][1:] line[2] = line[2].replace(' ', '') line[2] = line[2].replace('-', '') line[3] = line[3].replace('.', '/') line[3] = line[3][2:] line.pop() _list.sort() _list = list(map(list, zip(*_list))) return _list" "import re def d_d_c(table): for i in table: del i[0] del i[1] return table def toFixed(numObj, digits=0): return f'{numObj:.{digits}f}' def transformer(table): pos = '(\\d.\\d*)#(\\d*)\\/(\\d*)\\/(\\d*)' for j in table: str = j[1] mat = re.findall(pos, str) for i in mat: j[1] = i[3] + '.' + i[2] + '.' + i[1] j.append(toFixed(float(i[0]), 4)) if j[2] == 'Y': j[2] = '1' else: j[2] = '0' return table def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def transformName(table): name = '([А-Яа-я]*)\\s\\S.\\s([А-Яа-я]*)' for i in table: str = i[0] matches = re.findall(name, str) for j in matches: i[0] = j[1] + ' ' + j[0] return table def main(table): return transformer(transformName(d_d_c(table)))" "def change_row(row): row[0] = str(round(float(row[0]), 1)) row[1] = row[1].split('/') row[1].reverse() row[1] = '.'.join(row[1]) row[2] = row[2].replace('@', '[at]') return row def main(table): new = [] for row in table: if row in new: continue if not any(row): continue new.append(row) for i in range(len(new)): new[i] = change_row(new[i]) return new" "def main(table): b = [] for i in table: if i not in b and i.count(None) != 4: b.append(i) tab = [] for i in b: tmp = [] for j in i: if j and j not in tmp: tmp.append(j) tmp0 = tmp[0].split('!') tmp[0] = tmp0[1][7:10] + '-' + tmp0[1][11:13] + '-' + tmp0[1][13:15] tmp.insert(1, tmp0[0].replace('false', 'нет').replace('true', 'да')) tmp[2] = tmp[2].split('@')[1] tab.append(tmp) result = [] k = 0 for j in range(len(tab[0])): tmp = [] for i in range(len(tab)): tmp.append(tab[i][k]) k += 1 result.append(tmp) return result" "def main(lst): for i in lst: for p in i[:]: if p is None: i.remove(p) else: continue tmp = [] for i in lst: if i in tmp: continue else: tmp.append(i) for i in tmp: if len(i) == 0: tmp.remove(i) result = [] for element in tmp: name = element[0] name1 = element[0] name = name[name.rfind(' ') + 1:name.find('|')] + ' ' + name[0] + '.' name += name1[name1.find(' ') + 1:name1.find(' ') + 3] yes = element[0] yes = yes[yes.find('|') + 1:] yes = yesNo(yes) proc = float(element[1]) proc = str(round(proc, 2)) proc = proc[proc.find('.') + 1:] proc = num(proc) mail = element[2] mail = mail[:mail.find('[')] tmp1 = [] tmp1.append(yes) tmp1.append(proc) tmp1.append(mail) tmp1.append(name) result.append(tmp1) result = list(map(list, zip(*result))) return result def num(proc): if proc[0] == '0': proc = proc.replace('0', '') proc += '%' return proc elif len(proc) == 1: proc += '0%' return proc else: proc += '%' return proc def yesNo(state): if state == '1': return 'Да' else: return 'Нет'" "_row = [] def transpose(table): return [list(row) for row in list(zip(*table))] def delete_empty_rows(table): empty_row = len(table[0]) return [row for row in table if row is not empty_row] def delete_empty_columns(table): return [column[1:] for column in table] def delete_duplicate_rows(table): new_table = [] for el in table: if el not in new_table: new_table.append(el) return new_table def delete_duplicate_columns(table): for row in table: del row[3] return table def transformer(i, value): global _row if i == 0: _new_string = f'({value[2:5]}) {value[5:8]}-{value[8:10]}-{value[10:]}' return _new_string if i == 1: splited_string = value.split('!') _row.append('/'.join(splited_string[0].split('.'))) curr = splited_string[1].replace('%', '') return f'{int(curr) / 100:.1f}' if i == 2: name = value.split('.') return f'{name[0]}.' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): global _row _new_table = transform(transpose(delete_duplicate_rows(delete_duplicate_columns(delete_empty_columns(delete_empty_rows(table)))))) _new_table.append(_row) return _new_table" "def main(table): result_table = [] for a in range(len(table)): temp = [] for b in range(len(table[0])): if table[a][b] is None: continue if b == 0: tables = table[a][b].split('#') temp.insert(0, f'{tables[0][:-3]}{tables[0][-2:]}') email = tables[1].split('[at]') temp.insert(1, email[1]) if b == 1: table[a][b] = table[a][b].split(' ') temp.insert(2, f'{table[a][b][1][:-2]} {table[a][b][0]}') result_table.append(temp) return result_table" "import re def delete_none_rows(table): for i in range(len(table)): count = 0 j = 0 while j < len(table[i]) - 2: if table[i][j] is None: count += 1 if count == 2: del table[i] return table j += 1 else: j += 1 continue return table def delete_none_column(table): for row in table: del row[3] return table def to_fixed(num_obj, digits=0): return f'{num_obj:.{digits}f}' def transformer(table): for i in range(len(table)): name = table[i][0].split(' ') name = f'{name[2]}, {name[0][0]}.{name[1]}' table[i][0] = name for i in range(len(table)): exp = '\\[\\w+\\]\\w+\\.\\w+' mail = table[i][1].replace(''.join(re.findall(exp, table[i][1])), '') table[i][1] = mail for i in range(len(table)): table[i][2] = f'{table[i][2][3:6]} {table[i][2][7:11]}{table[i][2][11:13]}{table[i][2][14:]}' for i in range(len(table)): table[i][3] = to_fixed(float(table[i][3]), 2) return table def main(table): return transformer(delete_none_column(delete_none_rows(table)))" "def check(comp1, comp2): for i in range(0, len(comp2)): if comp1 == comp2[i]: return True return False def bro(mys, chs): for i in range(0, len(chs[0])): mys.append([]) for j in range(0, len(chs)): if i == j: mys[i].append(chs[i][j]) else: mys[i].append(chs[j][i]) def main(s): mys = [] chs = [] for row in s: cont = [] for elem in row: stri = str(elem) stri = stri.replace('да', '1') stri = stri.replace('нет', '0') if stri.find('@') != -1: stri = stri[:stri.find('@')] elem = stri if not check(elem, cont): if elem.find(';') == -1: cont.append(elem) else: elem = elem.split(';') for popa in elem: stri = popa if stri.find('-') == -1: stri = '%.2f' % float(stri) else: stri = stri.replace('+7', '') stri = stri.replace(' (', '') stri = stri.replace(')', '') stri = stri.replace('-', '!', 1) stri = stri.replace('-', '', 1) stri = stri.replace('!', '-', 1) cont.append(stri) if not check(cont, chs): chs.append(cont) bro(mys, chs) return mys" "def f10(listOfLists): resultingList = list() for column in listOfLists: col12 = column[1].split(';') col1 = col12[1].replace('.', '-') col2 = '{:.3f}'.format(round(float(col12[0]), 3)) col3 = column[2][3:] col = [col1, col2, col3] if col not in resultingList: resultingList.append(col) return resultingList def main(n): return f10(n)" "import re def main(table): x = len(table[0]) for j in range(0, x): try: while table[j].count(None) > 0: table[j].remove(None) x -= 1 table[j][0] = re.findall('...-....', table[j][0]) table[j][0] = table[j][0][0] table[j][0] = table[j][0][:6] + '-' + table[j][0][6:] rab_str = table[j][1] table[j][1] = re.findall('&.{1,}%', table[j][1]) table[j][1] = table[j][1][0] table[j][1] = table[j][1].replace('&', '') table[j][1] = table[j][1].replace('%', '') if len(table[j][1]) == 2: table[j][1] = '0.' + table[j][1] + '0' else: table[j][1] = '0.0' + table[j][1] + '0' rab_str = re.findall('.{1,}&', rab_str) rab_str = rab_str[0] rab_str = rab_str.replace('&', '') rab_str = rab_str.replace('-', '.') rab_str = rab_str[6] + rab_str[7] + rab_str[2:6] + rab_str[0] + rab_str[1] table[j].append(rab_str) except IndexError: pass return proverka(table) def proverka(table): table.reverse() for i in table: if table.count(i) != 1: while table.count(i) != 1: table.remove(i) table.reverse() return table" "import string import itertools def remove(string, n): first = string[:n] last = string[n + 1:] return first + last def main(table): parsed = set() (number, initials, state) = ([], [], []) table_reformed = [] for (_number, _initials, _state) in table: if _number in parsed or _number is None: continue parsed.add(_number) _number = remove(_number, 0) _number = remove(_number, 3) _number = remove(_number, 10) number.append(_number) _initials = remove(_initials, len(_initials) - 1) _initials = remove(_initials, len(_initials) - 1) _initials_name = _initials[len(_initials) - 2:] _initials_sur = _initials[:len(_initials) - 3] _initials = _initials_name + ' ' + _initials_sur _initials = remove(_initials, len(_initials) - 1) initials.append(_initials) state.append('true' if _state == 'Выполнено' else 'false') for i in range(len(number)): table_reformed.append([number[i], initials[i], state[i]]) return table_reformed" "def main(array): new_ar = [] for ar in array: output = [] for x in ar: if x is not None: if ';' in x: x = x.split(';') if x[0] == 'Y': output.append('1') else: output.append('0') x = x[1].split(' ') output.append(x[0][:2] + ' ' + x[1]) else: x = x[3:] x = x[:3] + '-' + x[3:] if x not in output: output.append(x) output.reverse() output.insert(0, output.pop()) if output not in new_ar: new_ar.append(output) return new_ar" "def main(table): temp = [] for row in table: if row not in temp and (not row[0] is None): temp.append(row) table = temp for row in table: elems = row[0].split('-') elems = elems[::-1] row[0] = '.'.join(elems) row[1] = row[1].replace('[at]', '@') elems = row[2 + 1].split(':') row[2] = ' '.join(elems[0].split(' ')[::-1]) row[3] = format(float(elems[1]), '.4f') return table" "def main(_list): non = [None, None, None, None] while non in _list: _list.remove(non) for i in _list: i[0] = i[0][i[0].find(' ') + 1:] + ' ' + i[0][:i[0].find('.') + 1] i[1] = i[2][:i[2].find('[at]')] i[2] = i[2][i[2].find('+') + 5:] i[3] = i[3].replace('true', 'Да') i[3] = i[3].replace('false', 'Нет') _list.sort() return _list" "def main(table): table = first(table) table = second(table) table = third(table) return table def first(table): for row in table: if None in row: row.remove(None) row.pop(3) return table def second(table): new_table = [] for row in table: if row not in new_table: new_table.append(row) return new_table def third(table): for row in table: row[0] = '.'.join(row[0].split('.')[::-1]) row[1] = 'Выполнено' if row[1] == '1' else 'Не выполнено' row[2] = row[2].split('[at]')[0] return table" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] row1 = [] row2 = [] row3 = [] row4 = [] for i in data: split = i[0].split(';') if split[1] == 'Y': i[0] = 'да' else: i[0] = 'нет' split2 = i[1].split(' ') i[1] = split2[0][0] + '.' + split2[1] + ' ' + split2[2] date = datetime.strptime(split[0], '%Y/%m/%d') i3 = i[2] i[2] = date.strftime('%Y.%m.%d') i.append(str(round(float(i3), 1))) row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) row4.append(i[3]) new_table.append(row1) new_table.append(row2) new_table.append(row3) new_table.append(row4) return new_table" "c = [] def change(s): s = list(filter(None, s)) percent = 0 for i in range(len(s)): if '-' in s[i]: if i % 4 == 0: s[i] = s[i].replace('-', '') else: s[i] = s[i].replace('-', '/') if ';' in s[i]: percent = s[i][:3] c.append(str(int(float(percent) * 100)) + '%') s[i] = s[i][4:] if ']' in s[i]: s[i] = s[i][:s[i].find('[')] + '@' + s[i][s[i].find(']'):][1:] return s def main(s): s = list(filter(None, s)) count = 0 for i in range(len(s)): if s[i][2] is not None: s[i] = change(s[i]) s[i] = s[i][:-1] s[i].append(c[count]) count += 1 res = list(filter(None, s)) my_new_list = [i for i in res if i.count(None) <= 0] return my_new_list" "def change(s): s = list(filter(None, s)) for i in range(len(s)): if ']' in s[i]: s[0] = s[i][s[i].index(']') + 1:] if '-' in s[i]: s[1] = s[i][:s[i].index('-')] + s[i][s[i].index('-') + 1:] else: s[2] = s[i].replace('.', '/') return s def new_lists(s): ns1 = [] ns2 = [] ns3 = [] for s_list in s: ns1.append(s_list[0]) ns2.append(s_list[1]) ns3.append(s_list[2]) ns = [ns1, ns2, ns3] return ns def main(s): for i in range(len(s)): s[i] = change(s[i]) s = list(filter(None, s)) return new_lists(s)" "def name(arr): for i in range(len(arr)): s = arr[i][0] s = s.replace(' ', '.').split('.') arr[i][0] = s[0] + ' ' + s[1] + '.' return arr def mail(arr): for i in range(len(arr)): s = arr[i][1] s = s.split('@') arr[i][1] = s[1] return arr def last(arr): for i in range(len(arr)): s = arr[i][3] if s[0] == 'В': arr[i][3] = '1' else: arr[i][3] = '0' return arr def date(arr): for i in range(len(arr)): d = arr[i][2].split('-') arr[i][2] = d[2] + '-' + d[1] + '-' + d[0] return arr def get_column(arr, index): column = [] for i in range(len(arr)): column.append(arr[i][index]) return column def transpose(arr): new_arr = [] for i in range(len(arr[0])): new_arr.append(get_column(arr, i)) return new_arr def split(arr): a1 = [] a2 = [] for i in arr[1]: res = i.split('&') a1.append(res[0]) a2.append(res[1]) arr.pop(1) arr.insert(1, a2) arr.insert(1, a1) return arr def delete_equal_lines(arr, index): result = False i = index + 1 while i < len(arr): if arr[index] == arr[i]: arr.pop(i) result = True i -= 1 i += 1 return [arr, result] def delete_none_lines(arr): i = 0 while i < len(arr): if arr[i][0] is None: arr.pop(i) i -= 1 i += 1 return arr def solve(arr): tab = arr tab = delete_none_lines(tab) tab = transpose(tab) tab = delete_none_lines(tab) tab = transpose(tab) i = 0 while i < len(tab): temp = delete_equal_lines(tab, i) tab = temp[0] if temp[1]: i -= 1 i += 1 tab = delete_none_lines(tab) tab = transpose(tab) tab = split(tab) tab = transpose(tab) tab = name(tab) tab = mail(tab) tab = date(tab) tab = last(tab) tab.sort(key=lambda x: x[0]) return tab def main(h): return solve(h)" "def change(s): s = list(filter(None, s)) s0 = s1 = s2 = s3 = '' for i in range(len(s)): if '+' in s[i]: s0 = s[0][s[0].index('(') + 1:s[0].index(')')] s0 += ' ' s0 += s[0][s[0].index(')') + 1:s[0].index('&') - 3] s0 += s[0][s[0].index('&') - 2:s[0].index('&')] if len(s[0][s[0].index('&') + 1:-1]) == 1: s1 = '0.0' + s[0][s[0].index('&') + 1:-1] + '00' elif len(s[0][s[0].index('&') + 1:-1]) == 2: s1 = '0.' + s[0][s[0].index('&') + 1:-1] + '00' else: s1 = '1.0000' elif '.' in s[i]: s2 = s[1].replace('.', '/') s2 = s2[:-4] + s2[-2:] else: s3 = s[2][s[2].index(' ') + 1:] + ' ' + s[2][:s[2].index(' ')] return [s0, s1, s2, s3] def new_lists(s): ns1 = [] ns2 = [] ns3 = [] ns4 = [] for s_list in s: ns1.append(s_list[0]) ns2.append(s_list[1]) ns3.append(s_list[2]) ns4.append(s_list[3]) ns = [ns1, ns2, ns3, ns4] return ns def sort_key(e): return int(e[0][:3]) def main(s): norep = [] for el in s: if el not in norep: norep.append(el) for i in range(len(norep)): norep[i] = list(filter(None, norep[i])) s = list(filter(None, norep)) for i in range(len(s)): s[i] = list(filter(None, s[i])) s[i] = change(s[i]) s = sorted(s, key=sort_key) return new_lists(s)" "def main(_list): for i in _list: while None in i: i.remove(None) i[0] = i[0] + '00' i[1] = i[1][i[1].find(',') + 2:i[1].find('.') + 1] + ' ' + i[1][:i[1].find(',')] i[3] = i[3].split('.') i[3].reverse() i[2] = '.'.join(i[3]) i[3] = i[4][i[4].find('[at]') + 4:] (i[0], i[1]) = (i[1], i[0]) i.pop() _list.sort() for i in _list: (i[0], i[1]) = (i[1], i[0]) for i in _list: if _list.count(i) > 1: _list.remove(i) return _list" "def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('/') i[n] = f'{hop[2][2:]}-{hop[1]}-{hop[0]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('1', 'Да') i[n] = i[n].replace('0', 'Нет') return lst def format_procent(lst, n): for i in lst: j = float(i[n]) * 100 i[n] = str(int(j)) + '%' return lst def surname_format(lst, n): for i in lst: i[n] = i[n].split(',')[0] + i[n].split(',')[1][:3] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n].replace(' ', '') i[n] = i[n].replace('-', '') return lst def email_format(lst, n): for i in lst: i[n] = i[n].replace('@', '[at]') return lst def main(lst): lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = true_format(lst, 1) lst = email_format(lst, 3) lst = format_procent(lst, 2) lst = surname_format(lst, 0) lst = transpose(lst) return lst" "def main(x): res = [] res2 = [] for i in range(len(x)): res.append([]) for j in x[i]: if j not in res[i]: res[i].append(j) ind = [] for i in range(len(res)): if None in res[i]: ind.append(i) for i in range(len(res)): if i not in ind: res2.append(res[i]) for i in range(len(res2)): (yn, date) = res2[i][2].split(';') res2[i][2] = date[:6] + date.split('/')[2][2:] if yn == 'Да': res2[i].append('1') else: res2[i].append('0') (t1, t2) = res2[i][0].split('[at]') res2[i][0] = t1 + '@' + t2 (n1, n2) = res2[i][1].split(',') res2[i][1] = n2.split('.')[0][1:] + '. ' + n1 res2 = sorted(res2, key=lambda x: x[0]) return res2" "from datetime import datetime import pprint import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[2] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] data.sort() new_table = [] row1 = [] row2 = [] row3 = [] for i in data: i[0] = re.sub('\\[at\\].*', '', i[0]) date = datetime.strptime(i[1], '%y/%m/%d') i[1] = date.strftime('%d-%m-%y') word = i[2] word = word.replace('Да', 'true') word = word.replace('Нет', 'false') i[2] = word row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) new_table.append(row1) new_table.append(row2) new_table.append(row3) return new_table" "def main(x): res = [] for i in range(len(x)): res.append([]) for j in x[i]: if j: res[i].append(j) for i in range(len(res)): (p, f) = res[i][0].split('!') (p1, p2) = p.split('[at]') p = p1 + '@' + p2 f1 = f.split('.')[0] f = f1[-1] + '. ' + f1[:-2] n = res[i][1] n1 = n[:2] + ' ' + n[3:6] + ' ' + n[7:] res[i][0] = f res[i][1] = n1 res[i].append(p) return res" "def main(table): for row in table[:]: if set(row) == {None}: table.remove(row) to_remove = [] for i in range(len(table)): for j in range(i + 1, len(table)): if table[i] == table[j]: to_remove.append(j) for k in to_remove: table.pop(k) for row in table: row[0] = row[0] + '0' (bval, val) = row[1].split(';') (surname, name) = row[2].split(' ') row.append(name[:-2] + ' ' + surname) row[2] = val[:val.find('@')] if bval == 'Не выполнено': row[1] = 'Нет' else: row[1] = 'Да' pass table.sort(key=lambda x: x[3]) return [list(x) for x in zip(*table)]" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('/') i[n] = f'{hop[2][2:]}-{hop[1]}-{hop[0]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('Да', 'Y') i[n] = i[n].replace('Нет', 'N') return lst def format_procent(lst, n): for i in lst: j = int(i[n][:-1]) / 100 i[n] = '{0:.3f}'.format(j) return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = f'{j[2]}, {j[0][:1]}.{j[1]}' return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][6:12] + '-' + i[n][12:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].replace('@', '[at]') return lst def main(lst): lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = true_format(lst, 0) lst = format_procent(lst, 1) lst = surname_format(lst, 2) lst = telephone_format(lst, 3) return lst" "def main(my_list): table = [] for i in my_list: if i not in table: table.append(i) names = [] percent = [] dates = [] result = [] for i in range(len(table)): if table[i][0] is not None: percent_p = table[i][0].replace('%', '') percent_p = round(int(percent_p) / 100, 1) percent.append(str(percent_p)) name = table[i][2].replace(' ', '')[4:] name2 = table[i][2] name2 = name2[0] names.append(name + ' ' + name2 + '.') date1 = table[i][3][:-4] date2 = table[i][3][:-2][3:] date3 = table[i][3][5:] date_str = date1 + '-' + date2 + '-' + date3 dates.append(date_str) result.append(percent) result.append(names) result.append(dates) return result" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def transformer(i, value): if i == 0: replaced = '(' + value.replace(' ', ') ') replaced = replaced[:12] + '-' + replaced[12:] return replaced if i == 1: digit = int(float(value) * 100.0) return str(digit) + '%' if i == 2: return 'Y' if value == 'да' else 'N' if i == 3: name = value.replace('.', ' ') name = name.split() return f'{name[0]} {name[1]}.' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_empty_rows(table)))" "def main(a: list): i = len(a) - 1 while i > 0: if a.count(a[i]) > 1: del a[i] i -= 1 res = [[], [], []] for i in range(len(a)): cell = a[i][0].split(';') name = cell[0].split(' ') res[0].append(name[1][:2] + ' ' + name[0]) res[1].append('(' + a[i][1][3:6] + ') ' + a[i][1][7:]) if cell[1] == '1': res[2].append('Выполнено') else: res[2].append('Не выполнено') return res" "def main(values): newval = [] for i in values: if i[0] is not None: percent = str(round(float(i[0].partition(';')[0]) * 100)) + '%' pochta = i[0].partition(']')[2] name = i[2].partition(' ')[0] bulka = 'нет' if i[4] == 'Y': bulka = 'да' newval.append([percent, name, pochta, bulka]) newval.sort(key=lambda x: x[1]) return newval" "def main(a: list): for i in range(len(a)): a[i][0] = a[i][0][:a[i][0].find(' ')] a[i][1] = a[i][1].replace('[at]', '@') a[i][2] = a[i][2][4:7] + ' ' + a[i][2][9:15] + a[i][2][-2:] del a[i][3] a[i][3] = a[i][3][-2:] + '-' + a[i][3][3:5] + '-' + a[i][3][:2] a.sort(key=lambda name: name[0]) return a" "import re def clear_repeat(data): temp_array = [] for i in range(len(data)): if data[i] in temp_array or data[i] == [] or data[i] == [None, None, None, None, None]: continue else: temp_array.append(data[i]) return temp_array def main(data): data = clear_repeat(data) new_table = [] for i in range(len(data)): new_table.append(get_new_table_row(data[i])) new_table = sorted(new_table, key=lambda x: x[2]) return new_table def get_new_table_row(row_data): new_row = [] new_row.append(row_data[0].replace('.', '-')) new_row.append(re.search('@[a-z.]+', row_data[1]).group(0)[1:]) name_data = row_data[2].split(' ') name = name_data[2] + ', ' + name_data[0][:1] + '.' + name_data[1] new_row.append(name) if row_data[3] == 'Выполнено': new_row.append('1') else: new_row.append('0') return new_row" "def delete_empty_columns(table): for row in table: del row[0] return table def transformer(i, value): if i == 0: replaced = value.replace('/', '.') return f'{replaced[6:]}{replaced[2:6]}{replaced[0:2]}' if i == 1: index = value.find('[at]') return value[0:index] if i == 2: return 'нет' if value == '0' else 'да' if i == 3: index = value.rindex('-') return f'{value[0:index]}{value[index + 1:]}' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(delete_empty_columns(table))" "def main(table): b = [] for i in table: if i not in b: b.append(i) tab = [] for i in b: tmp = [] for j in i: if j and j not in tmp: tmp.append(j) tmp[0] = tmp[0].lower() tmp[1] = tmp[1][:len(tmp[1]) - 2].replace(',', '') tmp[2] = tmp[2].replace('@', '[at]') tmp[3] = tmp[3][3:].replace(')', '').replace('-', '') tab.append(tmp) return tab" "def main(array): new_array = [] for elem in array: if [None for i in range(4)] != elem: elem[1] = elem[1].split('.') (elem[1][0], elem[1][2]) = (elem[1][2], elem[1][0]) elem[1] = '-'.join(elem[1]) if elem[2] == '1': elem[2] = 'Выполнено' else: elem[2] = 'Не выполнено' f1 = elem[3].split()[0][0] f2 = elem[3].split()[1] f3 = elem[3].split()[2] elem[3] = f1 + '.' + f2 + ' ' + f3 new_array.append(elem[1:]) return new_array" "def main(a: list): for i in range(len(a)): a[i][0] = '1' if a[i][0] == 'Да' else '0' a[i][1] = '%.2f' % round(float(a[i][1]), 2) a[i][2] = a[i][2][4:].replace('-', '') name = a[i][3].split(' ') a[i][3] = name[2] + ' ' + name[0] return a" "def main(table): table = first(table) table = second(table) return table def first(table): new_table = [] for row in table: row.pop(2) row[0] = row[0].split(':') row[2] = row[0][0] row[0] = row[0][1] if row not in new_table: new_table.append(row) return new_table def second(table): for row in table: row[0] = row[0].split(' ')[1] row[1] = row[1].split('-') row[1] = f'({row[1][0]}) {row[1][1]}-{row[1][2]}' row[2] = str(round(float(row[2]), 1)) return [[table[j][i] for j in range(len(table))] for i in range(len(table[0]))]" "import re def rep(a, r=lambda a: [*filter(bool, a)]): a = r([r(x) for x in a]) no_seted = [*a] return [*sorted([*map(lambda x: x.split('~'), [*{*map(lambda x: '~'.join(x), a)}])], key=no_seted.index)] def main(a, r=re.search): a = rep(a) a = sorted(a, key=lambda x: x[0]) num = [r('\\+\\d+', a[i][0])[0] for i in range(len(a))] n = [f'{i[:2]} {i[2:5]} {i[5:8]}-{i[8:10]}-{i[10:12]}' for i in num] name = [re.findall('(?<=!)[а-яА-Я]|[а-яА-Я]\\.|[а-яА-Я]+$', a[i][0]) for i in range(len(a))] nu = [f'{i[0]}.{i[1]} {i[2]}' for i in name] mail = [r('\\w+\\.\\w+', a[i][1])[0] for i in range(len(a))] return [n, nu, mail]" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): for row in table: del row[2] return table def delete_duplicate_rows(table): temp_table = [] for i in table: if i not in temp_table: temp_table.append(i) return temp_table def get_normal_surs(table): for row in table: row[1] = row[1][0:2] + row[1][4:] return table def main(table): temp_table = [] delete_duplicate_columns(table) table = delete_duplicate_rows(table) table = get_normal_surs(table) for row in table: if row[0] is not None: tmp = [] for r in row: if r is not None: tmp.append(r) temp_table.append(tmp) for i in range(len(temp_table)): string = temp_table[i][0].split('#') num = float(string[1]) num = f'{num:.2f}' string[1] = num string[0] = string[0].replace('-', '') temp_table[i].append(string[0]) temp_table[i][0] = temp_table[i][0].replace(temp_table[i][0], string[1]) temp_table = transpose(temp_table) return temp_table" "def delete_empty_and_duplicate_columns(table): for row in table: del row[3] del row[2] return table def delete_duplicate_row(table): temp_table = [] for item in table: if item not in temp_table: temp_table.append(item) return temp_table def transform_row_with_name(table): temp_table = [] for i in range(len(table)): for j in range(len(table[i])): if j == 0: table[i][j] = table[i][j].split('|') table[i][j][0] = table[i][j][0].replace('+7', '') table[i][j][1] = table[i][j][1].split() table[i][j][1] = f'{table[i][j][1][0][0]}.{table[i][j][1][1]} {table[i][j][1][2]}' temp_table.append(table[i][j]) else: table[i][j] = table[i][j].replace('%', '') table[i][j] = str(round(float(table[i][j]) / 100, 2)) if len(table[i][j]) == 3: table[i][j] += '0' temp_table[j - 1 + i].append(table[i][j]) return temp_table def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) (response[0], response[1]) = (response[1], response[0]) return response def main(table): return transpose(transform_row_with_name(delete_duplicate_row(delete_empty_and_duplicate_columns(table))))" "import re def delete_columns(table): for column in table: del column[1] del column[3] del column[2] return table def trans(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def transformer(i, value): if i == 0: email = value emailRegex = '\\[at\\][\\w.]+' domain = re.findall(emailRegex, email)[0][4:] return domain if i == 1: name = value nameRegex = '[а-яА-яёЁ]{2,}' formattedName = re.findall(nameRegex, name)[0] formattedSurname = re.findall(nameRegex, name)[1] fullName = formattedSurname + ' ' + formattedName return fullName if i == 2: phoneNumber = value return mapper(phoneNumber) def transf(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def mapper(phone) -> str: first = phone[2:5] second = phone[5:8] third = phone[8:12] return first + '-' + second + '-' + third def main(table): return transf(trans(sorted(delete_columns(table), key=lambda k: k[2])))" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def transformer(i, value): if i == 0: digit = float(value) digit = round(digit, 2) return f'{digit:.2f}' if i == 1: num = value.find('@') valve = value[num + 1:] return valve if i == 2: return f""{value[6:] + '/' + value[3:5] + '/' + value[0:2]}"" if i == 3: return 'Выполнено' if value == '1' else 'Не выполнено' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_empty_rows(table)))" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('/') i[n] = f'{hop[2][2:]}-{hop[1]}-{hop[0]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('да', 'Да') i[n] = i[n].replace('нет', 'Нет') return lst def format_procent(lst, n): for i in lst: j = int(i[n][:-1]) / 100 i[n] = '{0:.3f}'.format(j) return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = f'{j[1]} {j[0]}' return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][6:12] + '-' + i[n][12:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].replace('@', '[at]') return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = true_format(lst, 0) lst = email_format(lst, 2) lst = surname_format(lst, 1) lst.sort(key=lambda x: x[2]) lst = transpose(lst) return lst" "def main(table): parsed = set() (email, phone_p, name_p, percent) = ([], [], [], []) for (data, phone, fullname, _, _, score) in table: if data in parsed or data is None: continue parsed.add(data) email.append(data.replace('[at]', '@')) phone_p.append(phone[3:].replace(' ', '').replace('-', '')) name_p.append(fullname[:-2]) percent.append(f'{round(float(score) * 100)}%') return [email, phone_p, name_p, percent]" "def main(x): x1 = [] for i in x: if i not in x1: x1.append(i) x = x1 for i in range(0, len(x)): x1 = [] for j in range(0, len(x[i])): if x[i][j] not in x1: x1.append(x[i][j]) x[i] = x1 if x[i][0] == 'Выполнено': x[i][0] = 'Y' else: x[i][0] = 'N' x[i][1] = x[i][1].replace('(', '').replace(') ', '-').rsplit('-', 1) x[i][1] = x[i][1][0] + x[i][1][1] x[i][2] = x[i][2][:x[i][2].find('.') + 1] return x" "import re def main(table): table = del_none(del_pov(table)) for i in range(len(table)): if table[i][0] == '1.0': table[i][0] = '100%' elif table[i][0] == '0.0': table[i][0] = '0%' elif len(table[i][0]) == 3: table[i][0] = table[i][0][2:] + '0%' else: table[i][0] = table[i][0][2:4] + '%' table[i][1] = table[i][1].replace('/', '-') table[i][2] = re.findall('.{1,}\\[', table[i][2]) table[i][2] = table[i][2][0] table[i][2] = table[i][2].replace('[', '') return perevertish(table) def perevertish(table): my_list_pers = [] my_list_data = [] my_list_name = [] for i in range(len(table)): my_list_pers.append(table[i][0]) my_list_data.append(table[i][1]) my_list_name.append(table[i][2]) table = [my_list_pers, my_list_data, my_list_name] return table def del_none(table): for elem in table: if elem == [None, None, None]: table.remove(elem) return table def del_pov(table): table.reverse() for i in table: while table.count(i) != 1: table.remove(i) table.reverse() return table" "def main(table): parsed = set() result = [] for (fullname, percent, _, email) in table: (surname, score, domain) = ([], [], []) if fullname in parsed or fullname is None: continue parsed.add(fullname) surname.append(fullname.split()[0]) score.append(f""{float(percent.strip('%')) / 100:.2f}"") domain.append(email.split('[at]')[1]) result.append([surname[0], score[0], domain[0]]) return sorted(result, key=lambda x: x[0])" "import re def main(a): for row in a: del row[3] for i in range(0, len(a)): log = re.split('@', a[i][2]) a[i][2] = log[0] for i in range(0, len(a)): b = a[i][0].split(' ') b[0] = b[0].replace(',', '') S = b[1] S = S[0] + S[1] fin = S + ' ' + b[0] a[i][0] = fin for i in range(0, len(a)): if 'Не' in a[i][1]: a[i][1] = 'нет' else: a[i][1] = 'да' response = [] for i in range(len(a[0])): response.append([]) for j in range(len(a)): response[i].append(a[j][i]) return response" "def main(y): dat = [] dat1 = [] result = [] pre_res = [] for i in y: if i not in dat1: dat1.append(i) for i in dat1: dat2 = [] for j in i: if j is not None: dat2.append(j) if len(dat2) != 0: dat.append(dat2) for i in dat: surname = i[0].split(':')[1].split(' ')[0] number = i[0].split(':')[0].split('-') number = number[2] + '-' + number[1] + '-' + number[0] phone = i[2].split(' ') phone = phone[0] + ' (' + phone[1] + ') ' + phone[2] pre_res.append(surname) pre_res.append(phone) pre_res.append(number) result.append(pre_res) pre_res = [] return result" "def main(table): a = [] for i in table: if i not in a: a.append(i) b = [] for i in a: c = [] for j in i: if j not in c: c.append(j) b.append(c) d = [i[0].split('!') + i[1:] for i in b] e = [['{}.{}.{}'.format(i[0][-2:], i[0][-5:-3], i[0][:2]), i[1].replace('[at]', '@'), i[2].replace('(', '').replace(')', ''), '0.' + '0' * (3 - len(i[3])) + i[3][:-1] + '00'] for i in d] f = [[], [], [], []] for i in e: f[0].append(i[0]) f[1].append(i[1]) f[2].append(i[2]) f[3].append(i[3]) return f" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): li = [] for row in table: if row not in li: li.append(row) return li def transformer(i, value): if i == 0: val = value.split(']') return val[1] if i == 1: value = value.replace('-', '.') value = value.replace('.20', '.') value = value.replace('.19', '.') return value if i == 2: if value != '1.0' and value != '0.0': name = value.split('.') return name[1] + '0%' elif value != '1.0': return '0%' else: return '100%' if i == 3: return 'Выполнено' if value == 'Y' else 'Не выполнено' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_duplicate_columns(delete_empty_rows(table))))" "def emptyCols(table): for x in table: del x[1] del x[1] return table def dupleRows(table): i = 0 while i < len(table): j = i + 1 while j < len(table): if table[i] == table[j]: del table[j] j -= 1 j += 1 i += 1 return table def emptyRows(table): for i in range(len(table)): if table[i][0] is None: del table[i] break return table def changes(table): for x in table: x[0] = x[0][:x[0].find('@')] if x[1] == '1': x[1] = 'Выполнено' else: x[1] = 'Не выполнено' x[2] = x[2][2:5] + '-' + x[2][5:8] + '-' + x[2][8:] return table def main(table): return changes(emptyRows(dupleRows(emptyCols(table))))" "import re def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_columns(table): for row in table: del row[0] del row[2] return table def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): for row in table: del row[2] return table def delete_duplicate_rows(table): temp_table = [] for i in table: if i not in temp_table: temp_table.append(i) return temp_table def get_normal_fullnames(table): for row in table: row[1] = row[1][0:2] + row[1][4:] return table def switch_true_false_column(table): for row in table: if row[0] == 'true': row[0] = 'Да' elif row[0] == 'false': row[0] = 'Нет' return table def main(table): temp_table = [] delete_empty_columns(table) table = delete_empty_rows(table) table = delete_duplicate_rows(table) table = get_normal_fullnames(table) table = switch_true_false_column(table) for row in table: if row[0] is not None: tmp = [] for r in row: if r is not None: tmp.append(r) temp_table.append(tmp) for i in range(len(temp_table)): string = temp_table[i][1].split('|') num = float(temp_table[i][2]) num = round(num, 1) temp_table[i][2] = str(num) full_name_string = string[0] email_name_string = string[1] email_name_string = re.sub('@[a-z.]*', '', email_name_string) temp_table[i].append(email_name_string) temp_table[i][1] = temp_table[i][1].replace(temp_table[i][1], full_name_string) temp_table = transpose(temp_table) return temp_table" "def main(table): parsed = set() result = [] for (fullname, percent, email) in table: (fullname_s, score, domain) = ([], [], []) if fullname in parsed or fullname is None: continue parsed.add(fullname) fullname_sp = fullname.split() fullname_s.append(f'{fullname_sp[2]}, {fullname_sp[0][0]}.{fullname_sp[1]}') score.append(f""{float(percent.strip('%')) / 100:.1f}"") domain.append(email.split('[at]')[1]) result.append([fullname_s[0], score[0], domain[0]]) return sorted(result, key=lambda x: x[0])" "def duplicateCols(table): for x in table: del x[4] return table def emptyCols(table): for x in table: del x[3] return table def emptyRows(table): for i in range(len(table)): if table[i][0] is None: del table[i] break return table def changes(table): for x in table: x[0] = x[0][0] + '.' + x[0][x[0].find(' ') + 1:] if x[1] == 'Да': x[1] = 'Y' else: x[1] = 'N' x[2] = str(round(float(x[2]), 1)) return table def sortby1(x): for i in range(len(x) - 1): for j in range(len(x) - 1 - i): if x[j][0] > x[j + 1][0]: (x[j], x[j + 1]) = (x[j + 1], x[j]) return x def trans(table): trans = [] for i in range(3): trans.append([]) for j in range(len(table)): trans[i].append(table[j][i]) return trans def main(table): return trans(sortby1(changes(emptyRows(emptyCols(duplicateCols(table))))))" "import re def main(table): table = rem_none_two(glob_none(povtorenii(table))) for i in range(len(table)): table[i] = povtorenii(table[i]) table[i][0] = table[i][0][:-2] table[i][1] = re.findall('@.{1,}', table[i][1]) table[i][1] = table[i][1][0] table[i][1] = table[i][1].replace('@', '') table[i][2] = table[i][2].replace('%', '') if len(table[i][2]) == 2: table[i][2] = '0.' + table[i][2] elif len(table[i][2]) == 3: table[i][2] = '1.00' else: table[i][2] = '0.0' + table[i][2] return new_tab(table) def new_tab(table): my_list_pers = [] my_list_data = [] my_list_name = [] for i in range(len(table)): my_list_pers.append(table[i][0]) my_list_data.append(table[i][1]) my_list_name.append(table[i][2]) table = [my_list_pers, my_list_data, my_list_name] return table def glob_none(table): for elem in table: if elem == [None, None, None, None, None, None]: table.remove(elem) return table def rem_none_two(table): for elem in table: while elem.count(None) != 0: elem.remove(None) return table def povtorenii(table): table.reverse() for i in table: while table.count(i) != 1: table.remove(i) table.reverse() return table" "def main(nbook): n2 = [] for i in nbook: if i not in n2 and i[0] is not None: n2.append(i) for i in range(0, len(n2)): if n2[i][3] == '0': n2[i][3] = 'нет' else: n2[i][3] = 'да' stroka = n2[i][0] stroka = stroka.split('.') stroka = stroka[0] + '.' stroka = stroka.replace(',', '') n2[i][0] = stroka stroka = str(n2[i][1]) stroka = round(float(stroka), 1) n2[i][1] = str(stroka) stroka = n2[i][2] stroka = stroka.replace('+7 ', '') n_stroka = '' n_stroka += stroka[0] + stroka[1] n_stroka += stroka[2] + '-' n_stroka += stroka[4] + stroka[5] n_stroka += stroka[6] + '-' n_stroka += stroka[-5] + stroka[-4] n_stroka += stroka[-2] + stroka[-1] n2[i][2] = n_stroka for j in range(len(n2) - 1): for i in range(len(n2) - 1): if n2[i] > n2[i + 1]: (n2[i], n2[i + 1]) = (n2[i + 1], n2[i]) return n2" "def main(table): parsed = set() (phone_p, res, s_name) = ([], [], []) for (_, phone, score, _, fullname) in table: if phone in parsed or phone is None: continue parsed.add(phone) phone_p.append(phone.replace('(', '').replace(')', '')) res.append('false' if score == '0' else 'true') s_name.append(fullname[:-2]) return [phone_p, res, s_name]" "def data_trans(string): new_string = [] for row in string: name = '' date = '' dig = '' for i in range(len(row)): if i == 0: name = row[i][-4] + '. ' + row[i].split(',')[0] elif i == 1: date = row[i].split('/') date = f'{date[2]}-{date[1]}-{date[0]}' elif i == 2: dig = '%.4f' % float(row[i]) new_string.append([name, date, dig]) return new_string def sort_matrix(string): return sorted(string) def transpose_matrix(string): trans_matrix = [[0 for j in range(len(string))] for i in range(len(string[0]))] for i in range(len(string)): for j in range(len(string[0])): trans_matrix[j][i] = string[i][j] return trans_matrix def delete_duplicates(string): duplicates = [] new_string = [] for row in string: if row[0] in duplicates: continue else: duplicates.append(row[0]) new_string.append(row) return new_string def delete_empty(string): new_string = [] for row in string: stri = [] for i in range(len(string[0])): if i == 1: continue stri.append(row[i]) new_string.append(stri) return new_string def main(string): return transpose_matrix(sort_matrix(data_trans(delete_empty(delete_duplicates(string)))))" "def data_trans(string): new_string = [] for row in string: name = '' booldev = '' date = '' dig = '' for i in range(len(row)): if i == 3: name1 = row[i][0] + '.' name2 = row[i].split(' ')[1] name = name1 + name2 + ' ' + row[i].split(' ')[2] elif i == 0: date = row[i].split('-') date = f'{date[2]}-{date[1]}-{date[0]}' elif i == 1: if row[i] == 'Y': booldev = 'Да' else: booldev = 'Нет' elif i == 2: dig = '%.1f' % (float(row[i].replace('%', '')) / 100) new_string.append([date, booldev, dig, name]) return new_string def delete_empty(string): new_string = [] for row in string: stri = [] for i in range(len(string[0])): if i == 0: continue stri.append(row[i]) new_string.append(stri) return new_string def transpose_matrix(string): trans_matrix = [[0 for j in range(len(string))] for i in range(len(string[0]))] for i in range(len(string)): for j in range(len(string[0])): trans_matrix[j][i] = string[i][j] return trans_matrix def main(string): return transpose_matrix(data_trans(delete_empty(string)))" "def main(table): n3 = [] for i in table: for x in i: if x is None: i.remove(x) temp = [] for x in table: if x not in temp: temp.append(x) table = temp for row in table: del row[2] for i in range(0, len(table)): stroka = table[i][1] stroka = stroka.split('%') stroka0 = stroka[0] stroka = stroka[1] stroka = stroka.split('@') gp = table[i][0] gp = gp.split(' ') if len(stroka0) == 1: stroka0 = '0' + stroka0 table[i][1] = '0.' + stroka0 + '00' elif len(stroka0) == 3: table[i][1] = '1.0000' else: table[i][1] = '0.' + stroka0 + '00' n3.append([gp[1], table[i][1], stroka[1]]) return n3" "def main(nbook): n2 = [] for i in nbook: if i not in n2 and i[0] is not None: n2.append(i) for i in range(0, len(n2)): stroka = n2[i][2] stroka = stroka.replace('(', '') stroka = stroka.replace(') ', '') stroka = stroka.replace('-', '') n2[i][2] = stroka stroka = n2[i][0] stroka = stroka.split('#') stroka[0] = stroka[0].replace('[at]', '@') stroka[1] = stroka[1].replace('/', '-') new_stroka = '' for j in (8, 9, 2, 3, 4, 5, 0, 1): new_stroka += stroka[1][j] stroka[1] = new_stroka n2[i] = [stroka[1], stroka[0], n2[i][2]] for j in range(len(n2) - 1): for i in range(len(n2) - 1): if n2[i][2] > n2[i + 1][2]: (n2[i], n2[i + 1]) = (n2[i + 1], n2[i]) return n2" "def main(a: list): i = len(a) - 1 while i >= 0: if a.count(a[i]) > 1: del a[i] else: a[i][0] = a[i][0].replace('@', '[at]') a[i][1] = a[i][1][-2:] + '-' + a[i][1][5:8] + a[i][1][:4] a[i][2] = a[i][2] + '000' del a[i][3] del a[i][3] i -= 1 return a" "import itertools def main(tab): for i in tab: for _ in range(i.count(None)): i.remove(None) for i in tab: if not i: tab.remove(i) for i in range(len(tab)): tab[i] = list(dict.fromkeys(tab[i])) tab = list(map(list, zip(*tab))) for i in range(len(tab)): tab[i] = list(dict.fromkeys(tab[i])) for i in range(len(tab[0])): tab[0][i] = tab[0][i].split(' ')[-1].replace('-', '') tab[1][i] = tab[1][i].split(' ')[0] tab[2][i] = tab[2][i].split(']')[1] tab[3][i] = tab[3][i].split('/')[0] return tab" "def main(table1): for row_num in range(len(table1) - 1, -1, -1): for elem_num in range(len(table1[row_num]) - 1, -1, -1): if table1[row_num][elem_num] is None: table1[row_num].pop(elem_num) for row_num in range(len(table1) - 1, -1, -1): if not table1[row_num]: table1.pop(row_num) for row_num in range(len(table1) - 1, -1, -1): table1[row_num] = table1[row_num][0].split(':') + table1[row_num][1:] table1[row_num][-1] = table1[row_num][-1].replace('.', '/', 2) table1[row_num][1] = 'Y' if table1[row_num][1] == '1' else 'N' table1[row_num][0] = ' '.join(table1[row_num][0].split()[::-1]) table1[row_num][2] = table1[row_num][2].split('@')[0] table1[row_num].append(table1[row_num].pop(0)) table1 = [[table1[j][i] for j in range(len(table1))] for i in range(len(table1[0]))] return table1" "import re def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def add_extra_column(table): for i in range(len(table)): table[i][1] = re.split('\\|', table[i][0])[1] table[i][0] = re.split('\\|', table[i][0])[0] return table def transformer(i, value): if i == 0: return f'{value[0:2]}/{value[3:5]}/{value[6:8]}' if i == 1: return f'{value[0:13]}{value[14:16]}' if i == 2: return f""{value[0:value.find(',')]}{value[value.find(',') + 1:value.find('.') + 1]}"" def transform(table): for i in range(len(table[0])): for j in range(len(table)): table[j][i] = transformer(i, table[j][i]) return table def main(table): return transform(add_extra_column(table))" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def main(x): set_list = [] for i in x: if i not in set_list and None not in i: set_list.append(i) for i in set_list: i[0] = i[0][:i[0].find(',')] i[1] = i[1].replace('@', '[at]') i[2] = i[2][2:].replace('.', '-') i[3] = f'{i[3][6:9]}-{i[3][10:12]}-{i[3][12:14]}' set_list = transpose(set_list) return set_list" "import math def delete_repeats(table): a = [] for x in table: if x in table: if x not in a: a.append(x) return a def main(table): table = delete_repeats(table) for i in range(len(table)): for j in range(len(table[i])): if j == 0: if table[i][j] == 'Y': table[i][j] = 'Выполнено' else: table[i][j] = 'Не выполнено' if j == 1: table[i][j] = table[i][j].replace('(', '').replace(')', '') elif j == 2: table[i][j] = str(format(float(table[i][j]), '.4f')) elif j == 3: table[i][j] = table[i][j][table[i][j].find('[at]') + 4:] out = list(map(list, zip(*table))) return out" "def main(x): set_list = [] for i in x: if i[0:3] not in set_list: set_list.append(i[:3]) for i in set_list: i[0] = 'Y' if i[0] == '1' else 'N' i[1] = f'{int(round(float(i[1]), 2) * 100)}%' i[2] = i[2].split(' ')[0] return set_list" "def main(x): for i in range(0, len(x)): x1 = [] for j in range(0, len(x[i])): if x[i][j] is not None and x[i][j] not in x1: x1.append(x[i][j]) x[i] = x1 x1 = [] for i in x: if i != []: x1.append(i) x = x1 for i in range(0, len(x)): x[i].append(x[i][0][x[i][0].find(' ') + 1:-2]) if x[i][0][-1] == '0': x[i][0] = 'N' else: x[i][0] = 'Y' x[i][1] = x[i][1][:3] + '-' + x[i][1][3:] return x" "def main(table): parsed = set() (res, phone_p, percent, domain) = ([], [], [], []) for (ans, phone, score, _, _, email) in table: if phone in parsed or phone is None: continue parsed.add(phone) res.append('Y' if ans == 'Да' else 'N') phone_p.append(phone[7:]) percent.append(f'{round(float(score) * 100)}%') domain.append(email.split('[at]')[1]) return [res, phone_p, percent, domain]" "def main(_list): non = [None, None, None, None] while non in _list: _list.remove(non) for i in _list: i[0] = i[1][i[1].find('.') + 1:i[1].find('#')] + ' ' + i[1][0] + '.' + i[1][i[1].find(' ') + 1:i[1].find('.') + 1] i[0] = i[0].lstrip() i[1] = i[1][i[1].find('#') + 1:] temp = i[1].split('.') temp.reverse() i[1] = '/'.join(temp) i[2] = i[2].replace('+7', '') (i[1], i[2]) = (i[2], i[1]) i[3] = i[3].replace('[at]', '@') (i[0], i[3]) = (i[3], i[0]) _list.sort() for i in _list: (i[0], i[3]) = (i[3], i[0]) for i in _list: while _list.count(i) > 1: _list.remove(i) return _list" "def date(year, month, day): return day + '/' + month + '/' + year def no_yes(word): if word == 'Нет': return 'Не выполнено' elif word == 'Да': return 'Выполнено' def names(name, surname): return surname + ' ' + name def main(input): a = [] k = 0 for i in range(len(input)): if len(list(filter(None, input[i]))) < 1: a.append(1) a.remove(a[i]) else: a.append(list(filter(None, input[i]))) if len(a) == 3: result = [[], [], []] elif len(a) == 4: result = [[], [], [], []] elif len(a) == 5: result = [[], [], [], []] for row in a: day = row[0][row[0].index('/') + 4:] month = row[0][row[0].index('/') + 1:-3] year = row[0][:row[0].index('/')] surname = row[2][row[2].index('.') + 2:] name = row[2][:row[2].index('.') - 2] result[k].append(date(year, month, day)) result[k].append(no_yes(row[1])) result[k].append(names(name, surname)) result[k].append(row[4].replace('@', '[at]')) k += 1 return sorted(result, key=lambda x: x[3])" "def delete_empty_rows(table): return [row for row in table if row[0] is not None] def set_round(table): for i in range(len(table)): table[i][3] = str(round(float(table[i][3]), 1)) table[i][2] = table[i][2].split('.') kas = table[i][2][2] + '/' + table[i][2][1] + '/' + table[i][2][0] table[i][2] = kas table[i][0] = table[i][0].replace('[at]', '@') split = table[i][1].split(' ') table[i][1] = split[0] table.sort(key=lambda k: k[1]) return table def main(table): return set_round(delete_empty_rows(table))" "import re def delete_duplicate_columns(table): for s in table: if s.count(None) == len(s): table.remove(s) table = [[s[i] for s in table] for i in range(len(table[0]))] return table def delete_empty_columns_and_rows(table): for s in table: for i in range(table.count(s) - 1): table.remove(s) if s.count(None) == len(s): table.remove(s) table = [[s[i] for s in table] for i in range(len(table[0]))] return table def transformer(table): for i in range(len(table)): r = re.split('\\s', table[i][0]) table[i][0] = r[2] + ' ' + r[0][0] + '.' + r[1] table[i][1] = table[i][1][2:4] + '/' + table[i][1][5:7] + '/' + table[i][1][8:10] table[i][2] = table[i][2][-8:] table[i][3] = re.search('\\w*', table[i][3]).group(0) return table def main(table): return transformer(delete_empty_columns_and_rows(delete_duplicate_columns(table)))" "def main(_list): for i in _list: i[0] = i[0][i[0].find('@') + 1:] temp = i[1].split('.') temp.reverse() i[1] = '-'.join(temp) temp = i[2].split() temp.reverse() i[2] = ' '.join(temp) i[3] = i[3][i[3].find(' ') + 1:] i[3] = i[3].replace('-', '') _list.reverse() for i in _list: while _list.count(i) > 1: _list.remove(i) _list.reverse() _list = list(map(list, zip(*_list))) return _list" "def main(list): toRemove = [] for i in range(len(list)): for j in range(i + 1, len(list)): if list[i] == list[j]: toRemove.append(j) for x in toRemove: list.pop(x) new_list = [[], [], []] for i in range(len(list)): row = list[i][0].split('#') row2 = list[i][1].split() new_list[0].append('.'.join(row[1].split('/')[::-1])) new_list[1].append(row2[-1] + ' ' + row2[0]) new_list[2].append('-'.join([row[0][5:8], row[0][8:]])) return new_list" "def main(input_table): return_table = [] filtered_table = [] for row in input_table: if row[0] is None: continue row = list(filter(lambda elem: elem is not None, row)) row.pop(-1) if row in filtered_table: continue filtered_table.append(row) for row in range(len(filtered_table)): return_table.append([x for x in range(3)]) for i in range(len(filtered_table)): [name, date] = filtered_table[i][0].split(':') is_completed = filtered_table[i][1] == 'Выполнено' [firstname, otch, surname] = name.split(' ') return_table[i][0] = '%s %s.%s.' % (surname, firstname[0], otch[0]) return_table[i][1] = date.replace('.', '-') return_table[i][2] = 'да' if is_completed else 'нет' return return_table" "def main(table): b = [] for i in table: if i not in b and i.count(None) != 5: b.append(i) tab = [] for i in b: tmp = [] for j in i: if j and j not in tmp: tmp.append(j) tmp[0] = tmp[0].replace('Нет', 'N').replace('Да', 'Y') tmp[1] = tmp[1][0:2] + '(' + tmp[1][3:6] + ')' + tmp[1][7:13] + '-' + tmp[1][13:] tmp[2] = tmp[2].replace('@', '[at]') tmp[3] = tmp[3][:2] + tmp[3][4:] tab.append(tmp) result = [] k = 0 for j in range(len(tab[0])): tmp = [] for i in range(len(tab)): tmp.append(tab[i][k]) k += 1 result.append(tmp) return result" "from collections import OrderedDict from itertools import groupby def remove_duplicated_rows(lst): return list(OrderedDict(((tuple(x), x) for x in lst)).values()) def remove_empty_columns(lst): data = zip(*lst) data = [x for x in data if any(x)] return list(map(list, zip(*data))) def transpose(lst): return list(map(list, zip(*lst))) def remove_duplicated_columns(lst): data = zip(*lst) data = [x for x in data if not all_equal(x)] return list(map(list, zip(*data))) def all_equal(iterable): g = groupby(iterable) return next(g, True) and (not next(g, False)) def remove_empty_rows(lst): s = [] for ls in lst: if not all_equal(ls) and (not ls[0] is None): s.append(ls) return s def transform(lst): for row in lst: s = row[0].split() row[0] = f'{s[0]} {s[2]}' s2 = row[1].split('&') row[1] = '{:.4f}'.format(float(s2[1])) row.append(s2[0].replace(' ', '(', 1).replace(' ', ')', 1)) def main(table): table = remove_empty_columns(table) table = remove_empty_rows(table) transform(table) return table" "def main(table): parsed = set() result = [] for (data, score, _, fullname) in table: (phone, year, score_r, surname) = ([], [], [], []) if data in parsed or data is None: continue parsed.add(data) data_s = data.split(':') phone.append(f'({data_s[1].split()[0]}) {data_s[1].split()[1][0:3]}-{data_s[1].split()[1][4:6]}-{data_s[1].split()[1][6:8]}') year.append(data_s[0][-4:]) score_r.append(f'{score}000') surname.append(fullname.split()[1]) result.append([phone[0], year[0], score_r[0], surname[0]]) return result" "def main(v): for i in v: for j in i[:]: if j is None: i.remove(j) else: continue for i in v[:]: if len(i) == 0: v.remove(i) else: continue v1 = [] for row in v: mail = row[0] mail = mail[mail.find(']') + 1:] v2 = [] v2.append(mail) date = row[1] date = date.replace('-', '/') date = date[6:] + date[2:6] + date[:2] v2.append(date) p = row[2] p = float(p) p = round(p, 2) p = r(p) v2.append(p) last = row[4] last = last[:last.find(' ')] v2.append(last) v1.append(v2) v1.sort(key=lambda i: i[3]) return v1 def r(num): num = str(num) if num[2] != '0' and len(num) == 3: num += '0' return num else: return num" "def delete_empty_rows(table): return [row for row in table if row[0] is not None] def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_duplicate_columns(table): for row in table: del row[3] return table def sort(table): for i in range(len(table[0])): table[0][i] = table[0][i].split('|') date = [] number = [] for i in range(len(table[0])): date.append(table[0][i][0]) number.append(table[0][i][1]) for i in range(len(date)): kas = date[i] d = kas.split('/') date[i] = d[0] + '.' + d[1] + '.' + d[2] for i in range(len(number)): kas = number[i] d = kas.split(')') kas = d[1] d = kas.split('-') number[i] = d[0] + '-' + d[1] + d[2] table.append(table[1]) table[0] = number table[1] = date for i in range(len(table[2])): if table[2][i] == 'Да': table[2][i] = table[2][i].replace('Да', 'Выполнено') else: table[2][i] = table[2][i].replace('Нет', 'Не выполнено') return table def main(table): return sort(delete_empty_rows(transpose(delete_duplicate_columns(table))))" "import re def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_empty_columns(table): table = transpose(table) table = [row for row in table if row[0] is not None] return transpose(table) def transformer(i, value): if i == 0: digit_str = value.replace('%', '') digit = float(digit_str) / 100 return f'{digit:.4f}' if i == 2: p = '\\d\\d\\-\\d\\d-\\d\\d' matches = re.search(pattern=p, string=value).group() return matches.replace('-', '.') if i == 1: return '1' if value == 'Y' else '0' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(delete_empty_columns(delete_empty_rows(table)))" "def main(table): h = len(table) result = [] for i in range(h): r = table[i] c1 = str(r[0]) c2 = str(r[1]) c3 = float(r[2]) num = c1[:c1.index('!')].replace('-', '') tokens = c1.split() name = tokens[len(tokens) - 1] email = c2.replace('@', '[at]') result.append([num, name, email, f'{round(c3, 3):.3f}']) return sorted(result, key=lambda n: n[2])" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def del_empty_columns(table): for i in range(0, len(table)): table[i] = list(filter(None, table[i])) return table def del_duplicate_rows(table): table = list(reversed(table)) for x in table: if table.count(x) > 1: table.remove(x) return list(reversed(table)) def transformer(i, value): global bl bl = '' if value is None: return '' if i == 0: return value[:-2] if i == 1: replaced = value.replace('.', '/') return replaced if i == 2: phone = value.split(':') bl = phone[1] return phone[0][7:] if i == 3: return 'true' if value == '1' else 'false' return value def transform(table): table.append([]) global bl for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) if bl != '': table[len(table) - 1].append(bl) return table def main(table): return transform(transpose(del_duplicate_rows(del_empty_columns(table))))" "def main(nbook): n2 = [] for i in nbook: if i not in n2 and i[0] is not None: n2.append(i) for i in range(len(n2)): del n2[i][1] del n2[i][1] stroka = n2[i][0] stroka = stroka.split('@') stroka0 = stroka[1] stroka = n2[i][1] stroka = stroka.split('#') if stroka[0] == 'нет': stroka1 = 'false' else: stroka1 = 'true' stroka = str(stroka[1]) stroka4 = '' for j in range(len(stroka) - 1): stroka4 += stroka[j] stroka4 = str(float(stroka4) / 100) if len(stroka4) == 3: stroka4 += '0' stroka = n2[i][2].split(' ') stroka3 = stroka[2] + ' ' + stroka[0] n2[i] = [stroka0, stroka1, stroka3, stroka4] return n2" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0]] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(-1) date = datetime.strptime(i[0], '%Y/%m/%d') i[0] = date.strftime('%d.%m.%Y') split = i[1].split(' ') i[1] = split[1][:2] + ' ' + split[0][:-1] i2 = i[2] i[2] = i2[:2] + ' (' + i2[2:5] + ') ' + i2[5:8] + '-' i[2] += i2[8:10] + '-' + i2[10:] i[3] = i[3].replace('@', '[at]') row = [] row.append(i[3]) row.append(i[1]) row.append(i[2]) row.append(i[0]) new_table.append(row) new_table.sort() for i in new_table: (i[0], i[3]) = (i[3], i[0]) return new_table" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def transformer(i, value): if i == 0: replaced = value.split() new = replaced[0][0] + '.' + replaced[1] + ' ' + replaced[2] return new if i == 1: digit_str = value.replace('[at]', '@') return digit_str if i == 2: return 'Y' if value == 'да' else 'N' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def sort(table): table.sort(key=lambda x: x[1]) return table def main(table): return transpose(sort(transform(delete_empty_rows(table))))" "from operator import itemgetter def first(s): new = [] for i in s: if i not in new: new.append(i) return new def second(s): new = [] for i in s: cur = [] for j in i: if j is not None: cur.append(j) if len(cur) != 0: new.append(cur) return new def third(s): for i in s: i[0] = i[0].split(' ')[0] i[1] = i[1] + '00' if i[2] == 'да': i[2] = 'Y' elif i[2] == 'нет': i[2] = 'N' i[3] = i[3].split('/')[2] return s def fourth(s): new = sorted(s, key=itemgetter(0)) return new def main(s): return fourth(third(second(first(s))))" "def change(s): s = list(filter(None, s)) n_s = list() for i in range(len(s)): if 'Да' in s[i]: n_s.append('Y') if 'Нет' in s[i]: n_s.append('N') if '#' in s[i]: s[i] = s[i].replace('-', '/') s[i] = str(s[i][s[i].index('#') + 1:]) if '/' in s[i]: s1 = s[i].split('/') stroke = s1[2] + '/' + s1[1] + '/' + s1[0] n_s.append(stroke) if '-' in s[i]: s[i] = s[i].replace('-', '') if ' ' in s[i]: s[i] = s[i][7:] n_s.append(s[i]) return n_s def new_lists(s): ns1 = [] ns2 = [] ns3 = [] for s_list in s: ns1.append(s_list[0]) ns2.append(s_list[2]) ns3.append(s_list[1]) ns = [ns1, ns2, ns3] return ns def main(s): for i in range(len(s)): s[i] = change(s[i]) s = list(filter(None, s)) return new_lists(s)" "def main(x): x1 = [] for i in x: if i != [None, None, None, None, None]: x1.append(i) x = x1 for i in range(0, len(x)): x1 = [] for j in range(0, len(x[i])): if x[i][j] not in x1: x1.append(x[i][j]) x[i] = x1 if x[i][0] == 'false': x[i][0] = 'N' else: x[i][0] = 'Y' x[i][1] = x[i][1][x[i][1].find('[at]') + 4:] x[i][2] = x[i][2].replace('+7 (', '').replace(')', '').rsplit('-', 1) x[i][2] = x[i][2][0] + x[i][2][1] x[i][3] = x[i][3][x[i][3].find(' ') + 1:] return x" "def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): for row in table: del row[4] return table def transformer(i, value): if i == 1: replaced = value.replace('-', '/') return replaced[-2:] + '/' + replaced[3:5] + '/' + replaced[:2] if i == 2: return value.split()[1] if i == 3: return value.split(', ')[0] if i == 0: return 'Y' if value == 'Да' else 'N' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(delete_duplicate_columns(delete_empty_rows(table)))" "def main(table): new_table = list() for row in table: if row not in new_table: new_table.append(row) table = new_table for row in table: if row[0] == 'Нет': row[0] = 'Не выполнено' else: row[0] = 'Выполнено' row[1] = ''.join((str(round(float(row[1]) * 100)), '%')) row[2] = row[2].split(' ')[0] table = list(map(list, zip(*table))) return table" "def toFixed(numObj, digits=0): return f'{numObj:.{digits}f}' def main(table): tabel_res = table.copy() for i in range(len(table)): (yn, num) = tabel_res[i][0].split('#') tabel_res[i].append(table[i][2]) tabel_res[i][2] = table[i][1] tabel_res[i][1] = yn tabel_res[i][0] = num tabel_res[i][0] = '[at]'.join(table[i][0].split('@')[:]) tabel_res[i][1] = '-'.join(table[i][1].split('-')[::-1]) tabel_res[i][1] = table[i][1][2:] tabel_res[i][2] = table[i][2].split(' ')[1] tabel_res[i][3] = toFixed(int(table[i][3].split('%')[0]) / 100, 3) return tabel_res" "def del_row(s): s1 = [] for row in s: if row not in s1: s1.append(row) return s1 def transpose(s): s1 = [] for i in range(len(s[0])): s1.append([]) for j in range(len(s)): s1[i].append(s[j][i]) return s1 def main(s): s = transpose(s) s = [row for row in s if row[0] is not None] s = del_row(s) s = transpose(s) for row in s: x = row[1].split('/') row[1] = x[2] + '.' + x[1] + '.' + x[0] b = row[0].split('|') row[0] = b[0][0:2] + b[0][4:] b[1] = b[1].replace('@', '[at]') row.insert(1, b[1]) s = transpose(s) return s" "def main(table): parsed = set() (slashdate, number, domain, surname) = ([], [], [], []) for (date, percent, _, _, mail, name) in table: if date in parsed or date is None: continue parsed.add(date) slashdate.append(f'{date[-2:]}/{date[3:5]}/{date[:2]}') number.append(f""0.{'0' * (2 - len(percent[:-1]))}{percent[:-1]}0"") domain.append(mail.split('[at]')[-1]) surname.append(f'{name[5:]} {name[:2]}') return [slashdate, number, domain, surname]" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_duplicate_rows(table): for row in table: del row[2] return table def delete_duplicate_columns(table): row_pos = 0 copy_row_pos = 1 while row_pos < len(table): row = table[row_pos] while copy_row_pos < len(table): if row == table[copy_row_pos]: table.pop(copy_row_pos) else: copy_row_pos += 1 row_pos += 1 copy_row_pos = row_pos + 1 return table def column_split(table): for row in range(0, len(table)): str = table[row].pop(0) for char1 in range(0, len(str)): if str[char1] == '&': column1 = str[0:char1] column2 = str[char1 + 1:len(str)] table[row].insert(0, column1) table[row].insert(0, column2) return table def sort_by_column(table): table.sort(key=lambda i: i[1]) return table def transformer(i, value): if i == 0: for j in range(len(value)): if value[j] == ']': return value[j + 1:len(value)] if i == 1: return value[7:len(value)] if i == 2: if value == 'Не выполнено': return 'Нет' if value == 'Выполнено': return 'Да' if i == 3: float_val = float(value) value = str(round(float_val, 1)) return value def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transpose(sort_by_column(transform(column_split(delete_duplicate_columns(delete_duplicate_rows(table))))))" "def del_row(s): s1 = [] for row in s: if row not in s1: s1.append(row) return s1 def transpose(s): s1 = [] for i in range(len(s[0])): s1.append([]) for j in range(len(s)): s1[i].append(s[j][i]) return s1 def main(s): s = transpose(s) s = del_row(s) s = transpose(s) for row in s: row[0] = row[0].replace('@', '[at]') row[1] = str(format(float(row[1][:-1]) / 100, '.2f')) row[2] = row[2][0:2] + ' ' + row[2][2:5] + ' ' + row[2][5:8] + '-' + row[2][8:] if row[3] == '1': row[3] = 'Выполнено' else: row[3] = 'Не выполнено' return s" "def del_row(s): s1 = [] for row in s: if row not in s1: s1.append(row) return s1 def transpose(s): s1 = [] for i in range(len(s[0])): s1.append([]) for j in range(len(s)): s1[i].append(s[j][i]) return s1 def main(s): s = [row for row in s if row[0] is not None] s = del_row(s) for row in s: row[1] = row[1].replace(' ', '') row[1] = row[1].replace('-', '') buff = row[0].split(':') row[0] = format(float(buff[0]), '.2f') row.insert(1, buff[1].replace('@', '[at]')) s = transpose(s) return s" "def change_list(any_list): any_list[0] = any_list[0][7:] any_list[1] = str(round(float(any_list[1]), 1)) any_list.append(any_list[2][any_list[2].index('|') + 1:]) any_list[2] = any_list[2][:2] + any_list[2][4:any_list[2].index('|')] if any_list[3] == 'false': any_list[3] = 'нет' else: any_list[3] = 'да' return any_list def main(old_list): listn = [] for el in old_list: if el not in listn: listn.append(el) for i in range(len(listn)): listn[i][0] = None listn[i] = list(filter(None, listn[i])) listn = list(filter(None, listn)) new_list = [] for i in range(len(listn)): new_list.append(change_list(listn[i])) return listn" "def main(table): parsed = set() (percent, surname, domain, slashdate) = ([], [], [], []) for (num, name, mail, date) in table: if name in parsed or name is None: continue parsed.add(name) percent.append(f'{float(num):.0%}') surname.append(name.split('. ')[-1]) domain.append(mail.split('[at]')[-1]) slashdate.append(date.replace('.', '/')) return [percent, surname, domain, slashdate]" "def main(table: list): empty_columns_indexes = set() for line in table: for (index, column) in enumerate(line): if column is not None: empty_columns_indexes.add(index) numbers_set = {i for i in range(0, len(table[0]))} empty_columns_indexes = numbers_set.difference(empty_columns_indexes) empty_columns_indexes = list(empty_columns_indexes) while empty_columns_indexes: index = empty_columns_indexes.pop(0) for line in table: line.pop(index) empty_columns_indexes = [i - 1 for i in empty_columns_indexes] for line in table: line[0] = line[0][:line[0].index('@')] line.extend(line[1].split('|')) line[2] = round(float(line[2]), 1) del line[1] line[2] = line[2][line[2].find(' ') + 1:] (line[1], line[2]) = (line[2], str(line[1])) table = list(map(list, zip(*table))) return table" "def main(table): for row in table: del row[0] for row in table: source = row[1] row[1] = source.split('&')[0] row[2] = source.split('&')[1] for row in table: row[0] = row[0].split('@')[0] row[1] = row[1].replace('/', '-') row[2] = 'N' if row[2] == 'Нет' else 'Y' row[3] = row[3][3:] row[3] = row[3][:-3] + row[3][-2:] table = list(map(list, zip(*table))) return table" "def main(table): newTable = [] dubles = [] for row in table: if row in dubles: continue dubles.append(row) tempRow = [] tempRow.append(row[0][4:].replace(' ', '').replace('-', '')) if row[0][0] == '1': tempRow.append('Выполнено') else: tempRow.append('Не выполнено') tempRow.append(row[1].split(' ')[1]) newTable.append(tempRow) return newTable" "def delete_empty_columns(table): for row in table: del row[3] return table def delete_duplicate_rows(table): indexes = [] for i in range(len(table)): for k in range(1 + i, len(table)): if table[i] == table[k]: indexes.append(k) indexes = list(set(indexes)) if len(indexes) != 0: for i in range(len(indexes)): table.pop(indexes[i]) if i < len(indexes) - 1: indexes[i + 1] -= i + 1 return table def transformer(j, value): if j == 0: replaced = value.replace('@', ' ') split = replaced.split() del split[0] return f'{split[0]}' if j == 1: digreplaced = value.replace('/', ' ') digsplit = digreplaced.split() return f'{digsplit[2]}-{digsplit[1]}-{digsplit[0]}' if j == 2: number = value.split() return f'{number[0]}({number[1]}){number[2]}' if j == 3: return 'Да' if value == '1' else 'Нет' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(delete_duplicate_rows(delete_empty_columns(table)))" "def main(table): for row in table: del row[1] new_table = list() for row in table: if row not in new_table: new_table.append(row) table = new_table for i in range(0, len(table)): if table[i][0] is None: del table[i] break for row in table: (date, value) = row[0].split('#') value = ''.join((str(round(float(value) * 100)), '%')) date = '.'.join(date.split('.')[::-1]) (row[0], row[1]) = (value, date) if row[3] == 'N': row[3] = 'Нет' else: row[3] = 'Да' (surname, initials) = row[2].replace(' ', '').split(',') row[2] = ' '.join((surname, initials[:2])) table = list(map(list, zip(*table))) return table" "def main(table): b = [] for i in table: if i.count(None) != 5: mass = [] for j in i: if j: mass.append(j) mass[1] = mass[1].replace('нет', 'Не выполнено').replace('да', 'Выполнено') mass[0] = mass[0][3:] tmp = mass[2].split() mass[2] = tmp[2] + ' ' + tmp[0][0] + '.' + tmp[1] b.append(mass) return b" "def main(table): newTable = [] dubles = [] for row in table: if row in dubles or row[0] is None: continue dubles.append(row) tempRow = [] helpArray = row[0].split('|') if helpArray[0] == 'нет': tempRow.append('N') else: tempRow.append('Y') tempRow.append(row[1].split(' ')[1]) row3 = row[3].split('/') tempRow.append(row3[2][2:] + '-' + row3[1] + '-' + row3[0]) value = helpArray[1].replace('%', '') if int(value) > 9: tempRow.append('0.' + value) else: tempRow.append('0.0' + value) newTable.append(tempRow) return newTable" "def delete_empty_columns(table): for i in range(len(table)): table[i] = [cell for cell in table[i] if cell is not None] return table def delete_duplicate_rows(table): unique_list = [] for row in table: if row not in unique_list: unique_list.append(row) return unique_list def transformer(j, value): if j == 0: splitted = value.split('|') first = '(' + splitted[1].split()[1] + ') ' + splitted[1].split()[2] second = splitted[0].split('[at]')[1] return [first, second] if j == 2: splitted = value.split('-') return f'{splitted[2][2:]}/{splitted[1]}/{splitted[0]}' if j == 3: return 'нет' if value == 'false' else 'да' def transform(table): for i in range(len(table)): for j in range(len(table[i])): if j == 0: tmp = table[i][1:] table[i] = transformer(j, table[i][j]) table[i] += tmp else: table[i][j + 1] = transformer(j + 1, table[i][j + 1]) return table def main(table): return transform(delete_duplicate_rows(delete_empty_columns(table)))" "import math def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_rows(table): res = [] for row in table: if row not in res: res.append(row) return res def transformer(i, j, table): value = table[i][j] if i == 0: return value[0].upper() + value[1:] if i == 1: temp = value.split('.') return temp[2] + '/' + temp[1] + '/' + temp[0][2:] if i == 2: temp = value.split('!') mail = temp[1].split('@') table[3][j] = mail[1] return '{:.2f}'.format(round(float(temp[0]), 2)) def transform(table): row = [] for i in range(len(table[0])): row.append('') table.append(row) for i in range(len(table) - 1): for j in range(len(table[i])): table[i][j] = transformer(i, j, table) return table def main(table): return transform(delete_empty_rows(transpose(delete_duplicate_rows(table))))" "def del_row(s): s1 = [] for row in s: if row not in s1: s1.append(row) return s1 def main(s): s = del_row(s) for row in s: row[0] = row[0][0:6] + row[0][8:10] if row[1] == 'true': row[1] = 'да' else: row[1] = 'нет' row[2] = str(round(float(row[2][2:4] + '.' + row[2][4:6]))) + '%' row[3] = row[3].replace('[at]', '@') return s" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('/') i[n] = f'{hop[2]}-{hop[1]}-{hop[0]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('Да', 'true') i[n] = i[n].replace('Нет', 'false') return lst def format_procent(lst, n): for i in lst: j = int(i[n][:-1]) / 100 i[n] = '{0:.3f}'.format(j) return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = f'{j[1]} {j[0]}' return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][3:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].replace('@', '[at]') return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = format_data(lst, 1) lst = true_format(lst, 2) lst = telephone_format(lst, 0) lst = transpose(lst) return lst" "def delete_empty_columns(table): clean_table = [] for row in table: clean_row = [value for value in row if value if not None] if len(clean_row): clean_table.append(clean_row) return clean_table def date_conv(date): split_date = date.split('/') new_date = f'{split_date[2]}.{split_date[1]}.{split_date[0][2:]}' return new_date def yn(table): new_table = [] yn_row = [] date_row = [] for value in table[1]: yn_row.append(value[1]) date_row.append(value[0]) for i in range(len(yn_row)): if yn_row[i] == 'Y': yn_row[i] = 'Да' if yn_row[i] == 'N': yn_row[i] = 'Нет' new_table.append(table[0]) new_table.append(yn_row) new_table.append(date_row) new_table.append(table[2]) return new_table def transformer(i, value): if i == 0: digit = float(value) return f'{digit:.4f}' if i == 1: split_value = value.split(':') split_value[0] = date_conv(split_value[0]) return split_value if i == 2: return value[5:] def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return yn(transform(transpose(delete_empty_columns(table))))" "def main(a: list): i = len(a) - 1 while i >= 0: if a.count(a[i]) > 1: del a[i] else: cell = a[i][3].split('#') a[i][0] = a[i][1].replace('@', '[at]') a[i][1] = a[i][2].replace(' ', '').replace('-', '') a[i][2] = cell[1][cell[1].find(' ') + 1:] a[i][3] = str(round(float(cell[0]), 1)) i -= 1 return a" "def del_row(s): s1 = [] for row in s: if row not in s1: s1.append(row) return s1 def main(s): s = [row for row in s if row[0] is not None] s = del_row(s) for row in s: buff = row[0].split(':') if buff[1] == 'Выполнено': buff[1] = '1' else: buff[1] = '0' row.insert(3, buff[1]) row[1] = row[1].split('@')[1] row[2] = row[2][0:3] + ' ' + row[2][3:6] + '-' + row[2][6:] row[0] = '/'.join(reversed(buff[0].split('/')))[2:] return s" "from audioop import reverse def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_duplicate_rows(table): for_deliting = [] for i in range(len(table) - 1): for j in range(i + 1, len(table)): if table[i] == table[j] and (not j in for_deliting): for_deliting.append(j) for i in reversed(for_deliting): del table[i] return table def transformer(i, value): if i == 0: return value[:value.find('[')] if i == 1: return '%.2f' % round(float(value), 2) if i == 2: name = value.split('-') name[0] = name[0].split() return f'({name[0][1]}) {name[0][2]}-{name[1]}{name[2]}' if i == 3: return 'да' if value == '1' else 'нет' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_duplicate_rows(table)))" "def main(a: list): i = len(a) - 1 while i >= 0: if a.count(a[i]) > 1: del a[i] else: del a[i][1] del a[i][3] del a[i][3] a[i][0] = a[i][0][:a[i][0].find(' ')] a[i][1] = 'да' if a[i][1] == 'true' else 'нет' a[i][2] = a[i][2].replace('@', '[at]') i -= 1 return a" "def main(table): newTable = [] for row in table: if row[0] is None: continue tempRow = [] helper = row[0].split('|') help2 = helper[1].replace('.', '-') tempRow.append(help2[:6] + help2[8:]) tempRow.append(f'{float(helper[0]):.2f}') tempRow.append(row[1].split('@')[0]) newTable.append(tempRow) newTable.sort(key=lambda s: s[2]) return newTable" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('-') i[n] = f'{hop[0]}.{hop[1]}.{hop[2]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('1', 'Y') i[n] = i[n].replace('0', 'N') return lst def format_procent(lst, n): for i in lst: j = float(i[n]) * 100 i[n] = str(int(j)) + '%' return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = j[0] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][3:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].replace('@', '[at]') return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = format_data(lst, 1) lst = true_format(lst, 3) lst = format_procent(lst, 0) lst = surname_format(lst, 2) lst.sort(key=lambda x: x[2]) return lst" "def main(table): prom = [[], [], []] for line in table: if line[0]: s = line[0].split('-') s2 = s[2] + '.' + s[1] + '.' + s[0] if s2 not in prom[0]: prom[0].append(s2) else: continue d = str(round(float(line[3]) * 100)) + '%' prom[1].append(d) if line[4] == 'да': prom[2].append('Выполнено') else: prom[2].append('Не выполнено') return prom" "def main(table): parsed = set() (score, surname, domain, date_p) = ([], [], [], []) for (data, email, date, _, _) in table: if data in parsed or data is None: continue parsed.add(data) data_sp = data.split('#') score.append(f'{float(data_sp[0]):.1f}') surname.append(data_sp[1].split()[1]) domain.append(email.split('[at]')[0]) date_sp = date.split('/') date_p.append(f'{date_sp[2]}-{date_sp[1]}-{date_sp[0][-2:]}') return [score, surname, domain, date_p]" "def main(a: list): i = 0 while i < len(a): del a[i][0] cell = a[i][0].split(':') name = cell[1].split(' ') a[i][0] = str(round(float(cell[0]), 1)) a[i][1] = a[i][1][:a[i][1].find('@')] a[i][2] = name[2] + ' ' + name[0][:1] + '.' + name[1] a[i][3] = a[i][3].replace('.', '-') i += 1 a.sort(key=lambda name: name[2]) return a" "import re def sort_m(table): table.sort(key=lambda k: k[3]) return table def swap(table, i, j): for m in range(len(table) - 1): table_copy = table[m][i] table[m][i] = table[m][j] table[m][j] = table_copy return table def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_rows(table): for i in range(len(table) - 1): for j in range(i + 1, len(table)): if table[i] == table[j]: table[j] = [None] * len(table[0]) return table def delete_duplicate_columns(table): for i in range(len(table)): table[i][3] = re.split('!', table[i][1])[1] table[i][1] = re.split('!', table[i][1])[0] return table def transformer(i, value): if i == 0: return value.replace('[at]', '@') if i == 1: return '%.3f' % round(float(value), 3) if i == 2: return f'{value[8:10]}-{value[5:7]}-{value[0:4]}' if i == 3: return f""{value[0:1]}.{value[value.find(' ') + 1:value.find('.') + 1]}{value[value.find('.') + 1:len(value)]}"" def transform(table): for i in range(len(table)): for j in range(len(table[0])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transpose(sort_m(transform(delete_duplicate_columns(delete_empty_rows(delete_duplicate_rows(delete_empty_rows(table)))))))" "import re def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): for row in table: del row[4] return table def transformer(i, value): if i == 0: digit = float(value) return f'{digit:.3f}' if i == 1: replace = value.replace('[at]', '@') return replace if i == 2: name = value.split(', ') return f'{name[-1][0]}. {name[0]}' if i == 3: return 'Y' if value == 'Да' else 'N' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(delete_duplicate_columns(delete_empty_rows(table)))" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('/') i[n] = f'{hop[0]}.{hop[1]}.{hop[2]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('Да', 'Y') i[n] = i[n].replace('Нет', 'N') return lst def format_procent(lst, n): for i in lst: j = round(float(i[n]), 2) * 100 i[n] = str(int(j)) + '%' return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = j[0][:-1] + ' ' + j[1][:2] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][3:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].replace('@', '[at]') return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = format_data(lst, 2) lst = true_format(lst, 3) lst = format_procent(lst, 1) lst = surname_format(lst, 0) lst = transpose(lst) return lst" "def main(nbook): n2 = [] for i in nbook: if i not in n2 and i[1] is not None: n2.append(i) n3 = [] for i in range(0, len(n2)): del n2[i][0] del n2[i][1] stroka = n2[i][0].split('#') stroka1 = stroka[0] if stroka1 == 'N': stroka1 = 'false' else: stroka1 = 'true' stroka2 = n2[i][1] stroka2 += '0' stroka3 = stroka[1] stroka3 = stroka3.replace('-', '') n3.append([stroka1, stroka2, stroka3]) nbook = [] for i in range(0, len(n3[0])): stroka = [] for j in range(len(n3)): stroka.append(n3[j][i]) nbook.append(stroka) return nbook" "from datetime import datetime def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): b = [[i for i in item if i is not None] for item in table] c = [item for item in b if item is not None] j = 0 lenlist = len(c) while j < lenlist: if c[j] == []: c.pop(j) lenlist -= 1 else: j += 1 return c def delete_duplicate_columns(table): for row in table: del row[2] return table def add_new_columns(table): for i in range(len(table)): binnum = table[i][2][0] if binnum == 'Y': binnum = '1' else: binnum = '0' newdate = table[i][2][2:10] date_obj = datetime.strptime(newdate, '%d-%m-%y') date_obj = date_obj.strftime('%y/%m/%d') table[i][2] = binnum table[i].append(date_obj) return table def transformer(j, value): if j == 0: replaced = value.replace('[at]', '@') return replaced if j == 1: value = value.replace(' ', '-') value = value.split('-') return f'{value[1]}-{value[2][0:2]}-{value[2][2:4]}' def transform(table): for i in range(len(table)): for j in range(len(table[i]) - 1): table[i][j] = transformer(j, table[i][j]) add_new_columns(table) return table def main(table): return transpose(transform(delete_duplicate_columns(delete_empty_rows(table))))" "import re def main(a): temp = [] for i in a: if i not in temp: temp.append(i) a = temp i = 0 while i < len(a): if a[i].count(None) == len(a[i]): a.remove(a[i]) else: if a[i][len(a[i]) - 1] == 'false': a[i][len(a[i]) - 1] = '0' a[i].remove('false') elif a[i][len(a[i]) - 1] == 'true': a[i][len(a[i]) - 1] = '1' a[i].remove('true') a[i][0] = str('%.3f' % (float(re.split('!', a[i][1])[1].replace('%', '')) / 100)) a[i][1] = re.split('@|!', a[i][1])[1] temp = a[i][2] a[i][2] = re.split(' ', temp)[0] a[i][2] += ' ' + re.split(' ', temp)[2] a[i].remove(None) (a[i][2], a[i][1]) = (a[i][1], a[i][2]) i += 1 return a" "def transposer(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_duplicate_columns(table): for row in table: del row[4] return table def delete_duplicate_rows(table): li = [] [li.append(x) for x in table if x not in li] table = li return table def transformer(idx, value): if idx == 0: value = value[2:] value = '(' + value[1:4] + ')' + value[4:11] + value[12:] return value elif idx == 1: value = value[:-6] return value elif idx == 2: value = value.replace('[at]', '@') return value else: value = str(round(round(float(value), 2) * 100)) + '%' return value def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transposer(transform(delete_duplicate_columns(delete_duplicate_rows(table))))" "def main(table): lines = [] toRemove = [] for line in range(len(table)): table[line][0] = '%.2f' % float(table[line][0]) table[line][1] = str(table[line][1]).replace(' ', '-') if table[line][2] == 'Y': table[line][2] = 'да' elif table[line][2] == 'N': table[line][2] = 'нет' if ''.join(table[line]) not in lines: lines.append(''.join(table[line])) else: toRemove.append(line) for line in toRemove: table.pop(line) return table" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(-1) split = i[0].split('&') i[0] = split[0].replace('[at]', '@') split1 = split[1].split(' ') i2 = i[2] i2 = i2[4:7] + ' ' + i2[9:15] + i2[16:] i.append(i2) if i[1] == 'да': i[2] = 'Выполнено' else: i[2] = 'Не выполнено' i[1] = split1[1] row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) row.append(i[3]) new_table.append(row) return new_table" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def add_new_row(table): a = [''] * len(table[0]) table.append(a) for j in range(len(table[0])): table[2][j] = table[0][j].split('%#')[1] table[0][j] = table[0][j].split('%#')[0] return table def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_rows(table): for i in range(len(table) - 1): for j in range(i + 1, len(table)): if table[i] == table[j]: table[j] = [None] * len(table[0]) return table def delete_duplicate_columns(table): for i in range(len(table) - 1): del table[i][2] return table def transformer(i, value): if i == 0: return '%.2f' % round(float(value) / 100, 2) if i == 1: return f""{value[value.find(' ') + 1:len(value)]} {value[0:value.find(' ')]}"" if i == 2: return value.replace('.', '-') def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(add_new_row(transpose(table)))" "def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[2] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(0) i.pop(0) i[0] = i[0][4:] if i[1] == '1.00': i[1] = '100%' else: i[1] = i[1].replace('0.', '') + '%' if i[1][0] == '0': i[1] = i[1][1:] if i[2] == 'Выполнено': i[2] = 'да' else: i[2] = 'нет' row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) new_table.append(row) new_table.sort() return new_table" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(-1) i.pop(1) date = datetime.strptime(i[0], '%y-%m-%d') i[0] = date.strftime('%d-%m-%y') i[1] = i[1].replace('-', '') if i[2] == 'false': i[2] = 'N' else: i[2] = 'Y' row = [] row.append(i[1]) row.append(i[0]) row.append(i[2]) new_table.append(row) new_table.sort() for i in new_table: (i[0], i[1]) = (i[1], i[0]) return new_table" "def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0]] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(-1) i.pop(-1) i[0] = i[0].replace('[at]', '@') i[1] = i[1][7:10] + i[1][11:] split = i[2].split(' ') i[2] = split[1][:-2] + ' ' + split[0][:-1] row = [] row.append(i[1]) row.append(i[0]) row.append(i[2]) new_table.append(row) new_table.sort() for i in new_table: (i[0], i[1]) = (i[1], i[0]) return new_table" "def delete_empty_columns(table): for row in table: del row[1] del row[2] return table def delete_duplicate_rows(table): table1 = [] check = [] for row in table: if row not in check: check.append(row) table1.append(row) return table1 def transform(table): for row in table: row[0] = '{:.3f}'.format(round(float(row[0]), 3)) row[1] = row[1].split(' ')[0] row[2] = row[2].replace('@', '[at]') return table def sor(table): table.sort(key=lambda x: x[1]) return table def main(table): return sor(transform(delete_empty_columns(delete_duplicate_rows(table))))" "import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] sort_table = [] row1 = [] row2 = [] row3 = [] row4 = [] for i in data: i[0] = i[0][:6] + '-' + i[0][6:] split = i[1].split(' ') i[1] = split[1] if i[2] == 'нет': i[2] = 'Нет' else: i[2] = 'Да' i[3] = re.sub('$', '%', i[3]) i[3] = i[3].replace('.', '') i[3] = re.sub('^0', '', i[3]) i[3] = re.sub('^0', '', i[3]) row = [] row.append(i[1]) row.append(i[0]) row.append(i[2]) row.append(i[3]) sort_table.append(row) sort_table.sort() for i in sort_table: row1.append(i[1]) row2.append(i[0]) row3.append(i[2]) row4.append(i[3]) new_table.append(row1) new_table.append(row2) new_table.append(row3) new_table.append(row4) return new_table" "def del_none(list): dup_free = [] for i in range(len(list)): if list[i][0] is not None: dup_free.append(list[i]) return dup_free def bol(list): for i in range(len(list)): if list[i][1] == 'Y': list[i][1] = '1' else: list[i][1] = '0' return list def name(list): j = 0 for j in range(len(list)): str = list[j][2] i = 0 i = str.find(' ', i) + 4 s = '' while i < len(str): s += str[i] i += 1 s += ', ' s += str[0] s += '.' i = 0 i = str.find(' ', i) + 1 s += str[i] s += '.' list[j][2] = s return list def date(list): for j in range(len(list)): str = list[j][0] s = '' s += str[0] s += str[1] s += '.' s += str[3] s += str[4] s += '.' s += str[8] s += str[9] list[j][0] = s return list def del_dup(list): for j in range(len(list)): del list[j][3] return list def main(list): return del_dup(name(bol(date(del_none(list)))))" "def main(table): new_table = [] not_nulls = [] for row in table: if row[0] is not None: not_nulls.append(row) for row in not_nulls: (name, patr, surname) = row[0].split() row[0] = ' '.join([surname, name]) (date, boolean) = row[1].split(';') (day, month, year) = date.split('/') row[1] = '/'.join([year, month, day]) if boolean == 'Y': row.append('Да') else: row.append('Нет') for i in range(len(not_nulls[0])): new_row = [] for row in not_nulls: new_row.append(row[i]) new_table.append(new_row) return new_table" "def main(_list): for i in _list: temp = i[0].split() temp.pop(1) i[0] = ' '.join(temp) temp = i[3].split('#') i[1] = temp[0] i[1] = i[1].replace('(', '') i[1] = i[1].replace(')', '') i[2] = temp[1] i.pop(len(i) - 1) i[2] = str(round(float(i[2]), 2)) if len(i[2]) == 3: i[2] += '0' i[2] = i[2].replace('0.', '') + '%' if i[2][0] == '0': i[2] = i[2][1:] return _list" "def delete_duplicate_columns(table): tableT = list(map(list, zip(*table))) for (i, row1) in enumerate(tableT): for (j, row2) in enumerate(tableT): if row1 == row2 and i != j: del tableT[j] return list(map(list, zip(*tableT))) def delete_empty_columns(table): tableT = list(map(list, zip(*table))) for (i, row) in enumerate(tableT): if row == [None] * len(row): del tableT[i] return list(map(list, zip(*tableT))) def delete_duplicate_rows(table): for (i, row1) in enumerate(table): for (j, row2) in enumerate(table): if row1 == row2 and i < j: table[j] = [None] * len(table[j]) return table def delete_empty_rows(table): table_cp = table.copy() deleted = 0 for (i, row) in enumerate(table): if row == [None] * len(row): del table_cp[i - deleted] deleted += 1 return table_cp def transformer(i, value): a = value if i % 3 == 0: a = f'{a[:2]}({a[2:5]}){a[5:8]}-{a[8:10]}-{a[10:]}' elif i % 3 == 1: a = f'{a[8:10]}/{a[5:7]}/{a[2:4]}' else: a = a.split() a = a[2] + ' ' + a[0] return a def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def sort_table(table): table.sort(key=lambda x: x[1]) return table def main(table): table = transform(delete_empty_rows(delete_duplicate_rows(delete_empty_columns(delete_duplicate_columns(table))))) return table" "def delete_empty_cols(table: list): for i in range(len(table)): table[i].pop(3) return table def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_rows(table): res = [] [res.append(item) for item in table if item not in res] return res def delete_duplicate_cols(table): for i in range(len(table)): table[i].pop(3) return table def transform(table): for col in range(len(table[0])): for row in range(len(table)): item = table[row][col] if col == 0: item = item.split() item = item[2] + ' ' + item[0][0] + '.' + item[1] table[row][col] = item if col == 1: item = item.replace('%', '') item = float(item) / 100 table[row][col] = f'{item:.3f}' if col == 2: item = item.split('@')[0] table[row][col] = item return table def main(table): return transform(delete_duplicate_rows(delete_duplicate_cols(delete_empty_rows(delete_empty_cols(table)))))" "def main(table): parsed = set() (res, domain, percent) = ([], [], []) for (data, score, _) in table: if data in parsed or data is None: continue parsed.add(data) data_s = data.split('!') res.append('Да' if data_s[0] == '1' else 'Нет') domain.append(data_s[1].split('[at]')[1]) percent.append(f'{round(float(score) * 100)}%') return [res, domain, percent]" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) response.insert(1, []) return response def delete_empty_rows(table): delL = [] for i in range(len(table)): for j in range(len(table[i])): if table[i][j] is None: delL.append(j) delL = set(delL) for i in range(len(table)): fg = 0 for el in delL: table[i].pop(el - fg) fg += 1 return table def delete_duplicate_columns(table): for row in table: del row[1] return table def transform(table): for i in range(len(table)): for j in range(len(table[i])): if i == 0: table[i][j] = table[i][j].replace('-', '.') if i == 2: (email, num) = table[2][j].split(':') if len(num) < 5: num += '0' if len(num) > 5: num = str(round(float(num), 3)) table[1].append(num) table[2][j] = email.replace('@', '[at]') return table def main(table): return transform(transpose(delete_duplicate_columns(delete_empty_rows(table))))" "def main(table): none_row = [None, None, None, None, None, None] while none_row in table: table.remove(none_row) for row in table: for i in row: if i is None: row.remove(i) (name, date) = row[0].split(';') name = refactor_name(name) date = refactor_date(date) email = row[3] email = refactor_email(email) if row[1] == 'N': row[1] = 'false' if row[1] == 'Y': row[1] = 'true' row[0] = name row[2] = email row[3] = date res = [] for row in table: if row not in res: res.append(row) for row in res: (row[1], row[2], row[3]) = (row[1], row[2], row[3]) res = list(map(list, zip(*res))) return res def refactor_date(dataq): data1 = dataq[0:2] data2 = dataq[3:5] data3 = dataq[6:] return data3 + '-' + data2 + '-' + data1 def refactor_name(name): name1 = name[0].upper() + '.' i = 0 while name[i] != ' ': i += 1 name2 = name[i + 1:i + 3] name3 = name[i + 4:] return name3 + ' ' + name1 + name2 def refactor_email(email): return email.replace('[at]', '@')" "def main(table): for t in table: tmp = t[0].split('/') t[0] = tmp[2] + '-' + tmp[1] + '-' + tmp[0] t[1] = t[1].split('[at]')[1] t[2] = str(round(float(t[2]), 1)) t[3] = t[3].split()[2] result = [] k = 0 for j in range(len(table[0])): tmp = [] for i in range(len(table)): tmp.append(table[i][k]) k += 1 result.append(tmp) return result" "def main(table): parsed = set() result = [] for (fullname, res, score, phone) in table: (surname, letter, percent, phone_p) = ([], [], [], []) if fullname in parsed or fullname is None: continue parsed.add(fullname) surname.append(fullname.split()[1]) letter.append('Y' if res == 'Выполнено' else 'N') percent.append(f'{round(float(score) * 100)}%') phone_p.append(phone.replace('-', '.')) result.append([surname[0], letter[0], percent[0], phone_p[0]]) return result" "def main(table): (slashdate, share, shortname) = ([], [], []) for (date, _, num, _, fullname, _) in table: slashdate.append(f'{date[-2:]}/{date[3:5]}/{date[:2]}') share.append(f'{num}00') (name, letter, surname) = fullname.split() shortname.append(f'{surname}, {name[0]}.{letter}') return [slashdate, share, shortname]" "def main(table): parsed = set() result = [] for (_, percent, data) in table: (score, email, res) = ([], [], []) if data in parsed or data is None: continue parsed.add(data) data_sp = data.split('&') score.append(str(round(float(percent.strip('%')) / 100.0, 1))) email.append(data_sp[0].replace('@', '[at]')) res.append('1' if data_sp[1] == 'да' else '0') result.append([score[0], email[0], res[0]]) return result" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('/') i[n] = f'{hop[0]}.{hop[1]}.{hop[2]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('false', 'Нет') i[n] = i[n].replace('true', 'Да') return lst def format_procent(lst, n): for i in lst: j = round(float(i[n]), 2) * 100 i[n] = str(int(j)) + '%' return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = j[0] + ' ' + j[1][:2] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][3:] i[n] = f'{i[n][:3]}-{i[n][3:5]}-{i[n][5:]}' return lst def email_format(lst, n): for i in lst: i[n] = i[n].replace('@', '[at]') return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = true_format(lst, 2) lst = surname_format(lst, 0) lst = telephone_format(lst, 1) lst = transpose(lst) return lst" "def main(a: list): for i in range(len(a)): del a[i][0] del a[i][1] a[i][0] = a[i][0][3:].replace(' ', '').replace('-', '') a[i][1] = a[i][1][a[i][1].find('@') + 1:] a[i][2] = 'Да' if a[i][2] == 'true' else 'Нет' return a" "def main(inp_tbl): result_tbl = [] nums = [] for (indx, i) in enumerate(inp_tbl): nums.append(i[1][4:7]) asd = round(float(i[-1]), 2) asd = str(asd) if len(asd) < 4: asd += '0' inp_tbl.insert(indx, [i[0], i[1][4:10] + '-' + i[1][10:], asd]) inp_tbl.remove(i) inp_tbl[indx][0] = inp_tbl[indx][0].replace('[at]', '@') nums = list(set(nums)) nums.sort() for i in nums: for i2 in inp_tbl: if i == i2[1][:3]: result_tbl.append(i2) break B = [[result_tbl[j][i] for j in range(len(result_tbl))] for i in range(len(result_tbl[0]))] return B" "from collections import OrderedDict from itertools import groupby def remove_duplicated_rows(lst): return list(OrderedDict(((tuple(x), x) for x in lst)).values()) def remove_empty_columns(lst): data = zip(*lst) data = [x for x in data if any(x)] return list(map(list, zip(*data))) def transpose(lst): return list(map(list, zip(*lst))) def remove_duplicated_columns(lst): data = zip(*lst) data = [x for x in data if not all_equal(x)] return list(map(list, zip(*data))) def all_equal(iterable): g = groupby(iterable) return next(g, True) and (not next(g, False)) def remove_empty_rows(lst): for ls in lst: if all_equal(ls) and ls[0] is None: lst.remove(ls) return lst def split_column_one_and_transform(lst): for ls in lst: s1 = ls[0].split(':') d1 = s1[0].split('.') ls[0] = '-'.join(d1[::-1]) ls[1] = ls[1][5:] ls[2] = ls[2].split('@')[1] ls.append('N' if s1[1] == 'Не выполнено' else 'Y') return lst def main(lst): lst = split_column_one_and_transform(lst) lst = transpose(lst) return lst" "def step1(table): for i in range(len(table)): del table[i][3] def step2(table): i_len = len(table) for i in range(i_len): if table[i][1] is None: del table[i][1] def step3(table): temp = [] for x in table: if x not in temp: temp.append(x) return temp def step4(table): for i in range(len(table)): (a, b) = table[i][0].split(';') table[i][0] = a table[i].insert(2, b) def step5(table): for i in range(len(table)): table[i][0] = table[i][0][2:] table[i][1] = table[i][1] + '00' table[i][2] = table[i][2].replace(' ', '-') def step6(table): trans_table = [[table[j][i] for j in range(len(table))] for i in range(len(table[0]))] return trans_table def main(table): step1(table) step2(table) table = step3(table) step4(table) step5(table) return step6(table)" "def main(a): r = [] for (email, number, fio, skip1, skip2, skip3) in a: fEmail = email.replace('@', '[at]') fNumber = number.replace('(', '').replace(')', '').replace('да#', '').replace('нет#', '') fFio = '' arrFio = fio.split(' ') fFio = fFio + arrFio[0][0] + '.' + arrFio[1] + ' ' + arrFio[2] if number.find('да') != -1: yesNo = '1' else: yesNo = '0' duplicate = False for (rEmail, rNumber, rFio, rYesNo) in r: if rEmail == fEmail and rNumber == fNumber and (rFio == fFio) and (rYesNo == yesNo): duplicate = True break if not duplicate: r.append([fEmail, fNumber, fFio, yesNo]) return r" "def delete_empty_columns(table): for i in range(len(table)): table[i] = [cell for cell in table[i] if cell is not None] return table def delete_duplicate_columns(table): for row in table: del row[4] return table def transformer(j, value): if j == 1: splitted = value.split('&') val_1 = str(round(float(splitted[0]), 2)) if len(val_1) == 3: val_1 = val_1 + '0' second = str(int(val_1[2:])) + '%' first = splitted[1][:6] + splitted[1][8:] return [first, second] if j == 0: return '0' if value == 'false' else '1' def transform(table): for i in range(len(table)): for j in range(len(table[i])): if j == 1: tmp = table[i][0] table[i] = transformer(j, table[i][j]) table[i] = [tmp] + table[i] else: table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(delete_empty_columns(delete_duplicate_columns(table)))" "def delete_duplicate_columns(table): table = transpose(table) result = [] for x in table: if x not in result: result.append(x) return transpose(result) def delete_duplicate_rows(table): result = [] for x in table: if x not in result: result.append(x) return result def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_columns(table): table = transpose(table) return transpose([row for row in table if row[0] is not None]) def transform(table): table = transpose(table) for i in range(len(table[0])): table[0][i] = table[0][i].split('#') table = transpose(table) for row in table: row.append(row[0][0]) row.append(row[0][1]) row.remove(row[0]) a = row[1] row[1] = row[0] row[0] = a if row[0] == 'N': row[0] = 'Нет' if row[0] == 'Y': row[0] = 'Да' row[1] = row[1][5:8] + '-' + row[1][8:] row[2] = row[2][:-2] return table def main(table): table = transform(delete_empty_columns(delete_duplicate_rows(delete_duplicate_columns(table)))) return table" "def main(table): parsed = set() (fullname_p, phone, res, date_p) = ([], [], [], []) for (fullname, data, date, _) in table: if data in parsed or data is None: continue parsed.add(data) data_s = data.split('&') res.append('1' if data_s[0] == 'Да' else '0') fullname_p.append(f'{fullname.split()[0][0:-1]} {fullname.split()[1][0:2]}') phone_s = data_s[1].split() phone.append(f""{phone_s[1].replace('(', '').replace(')', '')} {phone_s[2][0:6]}{phone_s[2][7:]}"") date_s = date.split('/') date_p.append(f'{date_s[2]}-{date_s[1]}-{date_s[0]}') return [fullname_p, phone, res, date_p]" "def main(nbook): n2 = nbook for i in range(0, len(n2)): if n2[i][1] == 'Не выполнено': n2[i][1] = 'N' else: n2[i][1] = 'Y' stroka1 = n2[i][1] stroka = n2[i][2] stroka = stroka.replace('[at]', '@') stroka2 = stroka stroka = n2[i][3] stroka = stroka.split('-') stroka3 = stroka[1] + '-' + stroka[2] n2[i] = [stroka1, stroka2, stroka3] nbook = [] for i in range(len(n2)): for i in range(len(n2) - 1): if n2[i][1] > n2[i + 1][1]: (n2[i], n2[i + 1]) = (n2[i + 1], n2[i]) for i in range(0, len(n2[0])): stroka = [] for j in range(len(n2)): stroka.append(n2[j][i]) nbook.append(stroka) return nbook" "from operator import itemgetter def first(s): for i in s: del i[3] del i[2] del i[0] return s def second(s): new = [] for i in s: if i[0] is not None: new.append(i) return new def third(s): for i in s: i[0] = i[0].replace('[at]', '@') buffer = '(' + i[1][2:5] + ') ' buffer = buffer + i[1][5:8] + '-' buffer = buffer + i[1][8:10] + '-' buffer = buffer + i[1][10:12] i[1] = buffer if i[2] == 'Нет': i[2] = 'Не выполнено' else: i[2] = 'Выполнено' return s def fourth(s): s = sorted(s, key=itemgetter(0)) return s def fifth(s): return list(map(list, zip(*s))) def main(s): return fifth(fourth(third(second(first(s)))))" "def main(table): tb = [] for t in table: mass = [] tmp = t[0].split('&') mass.append(tmp[0] + '0') mass.append(tmp[1].replace('-', '')) tmp2 = t[1].split('-') mass.append(tmp2[2] + '-' + tmp2[1] + '-' + tmp2[0]) tb.append(mass) result = [] k = 0 for j in range(len(tb[0])): tmp = [] for i in range(len(tb)): tmp.append(tb[i][k]) k += 1 result.append(tmp) return result" "def del_row(s): s1 = [] for row in s: if row not in s1: s1.append(row) return s1 def transpose(s): s1 = [] for i in range(len(s[0])): s1.append([]) for j in range(len(s)): s1[i].append(s[j][i]) return s1 def main(s): s = [row for row in s if row[0] is not None] s = transpose(s) s = [row for row in s if row[0] is not None] s = transpose(s) for row in s: row[0] = 'Выполнено' if row[0] == 'Y' else 'Не выполнено' row[1] = '-'.join(reversed(row[1].split('/'))) row[2] = row[2].split('.')[0].replace(',', '') + '.' row[3] = '(' + row[3][3:6] + ')' + row[3][6:13] + row[3][14:] return s" "def delete_empty_columns(table): for i in range(len(table)): for j in range(table[i].count(None)): table[i].remove(None) return table def delete_doubles(table): for i in range(len(table)): for j in range(i + 1, len(table)): if set(table[i]) == set(table[j]): table[j].clear() return [value for value in table if value] def toFixed(numObj, digits=0): return f'{numObj:.{digits}f}' def transform(table): for i in range(len(table)): for j in range(len(table[0])): if j == 0: table[i][j] = table[i][j].replace('да', '1') table[i][j] = table[i][j].replace('нет', '0') elif j == 1: for k in range(len(table[i][j])): if table[i][j][k] == '@': table[i][j] = table[i][j][:k] break elif j == 2: digit = str(round(float(str(table[i][j]).strip()), 2)) while len(digit) != 4: digit += '0' table[i][j] = digit elif j == 3: table[i][j] = table[i][j][3:] return table def sortby4th(table): response = [] for i in range(len(table)): k = '(999) 999-99-99' t = i for j in range(len(table)): if table[j][3] <= k: t = j k = table[t][3] response.append([]) response.append(table[t]) table.remove(table[t]) return [value for value in response if value] def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def main(table): return transpose(sortby4th(transform(delete_doubles(delete_empty_columns(table)))))" "def getData(s): return s[0][8:10] + '-' + s[0][5:7] + '-' + s[0][2:4] def getFloat(s): s = float(s[0][11:]) return '%.4f' % round(s, 4) def getPost(s): return s[1][s[1].index(']') + 1:] def main(s): s.reverse() for x in s: if s.count(x) > 1: s.remove(x) s.reverse() a = [] a.append([]) a.append([]) a.append([]) for i in range(len(s)): a[0].append(getData(s[i])) a[1].append(getFloat(s[i])) a[2].append(getPost(s[i])) return a" "def transpose(table): (x, y) = (len(table), len(table[0])) tr_table = [[0] * x for _ in range(y)] for i in range(y): for j in range(x): tr_table[i][j] = table[j][i] return tr_table def del_double(table): new_table = [] for row in table: if row not in new_table: new_table.append(row) return new_table def del_empty(table): new_table = [] for row in table: if any(row): new_table.append(row) return new_table def refactoring(table): for row in range(len(table)): for ceil in range(len(table[row])): if '@' in table[row][ceil]: k = table[row][ceil].find('@') table[row][ceil] = table[row][ceil][:k] if table[row][ceil].count('.') == 2: date = table[row][ceil].split('.') table[row][ceil] = '-'.join(date[::-1]) if '+' in table[row][ceil]: table[row][ceil] = table[row][ceil].replace(' ', '(', 1) table[row][ceil] = table[row][ceil].replace(' ', ')', 1) return table def main(table): table = transpose(del_empty(del_double(transpose(table)))) return transpose(refactoring(del_empty(del_double(table))))" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_duplicate_rows(table): new_dict = {x[3]: x for x in table} return list(new_dict.values()) def delete_duplicate_columns(table): for row in table: del row[2] return table def transformer(i, value): if i == 0: replaced = value.replace('-', '').replace('-', '') return replaced[4:] if i == 1: return 'Y' if value == 'true' else 'N' if i == 2: digit = float(value) return f'{digit:.4f}' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_duplicate_columns(delete_duplicate_rows(table))))" "def main(table): none_row = [None, None, None, None] while none_row in table: table.remove(none_row) for row in table: if row[0] == 'да': row[0] = '1' else: row[0] = '0' row[1] = mail(row[1]) row[2] = str('{0:.2f}'.format(float(row[2].replace('%', '')) / 100)) row[3] = numb(row[3]) for row in table: (row[1], row[2], row[3]) = (row[1], row[2], row[3]) table = list(map(list, zip(*table))) return table def mail(email): i = 0 res = '' while email[i] != '@': res += email[i] i += 1 return res def numb(nom): return nom[0:3] + '-' + nom[3:6] + '-' + nom[6:]" "def transformer(row): transformed = [] name_and_status = row[0].split('&') if name_and_status[1] == '1': transformed.append('Да') else: transformed.append('Нет') name = name_and_status[0].split(' ') transformed.append(name[1] + ' ' + name[0]) mail = row[1].split('[at]') transformed.append(mail[0]) date = row[2].split('.') transformed.append(date[2] + '.' + date[1] + '.' + date[0][-2:]) return transformed def transform(table): result = [] for i in range(len(table)): result.append(transformer(table[i])) return result def main(table): return transform(table)" "def main(table): dict = [] result = [[], [], [], []] table = delete_empty_rows(table) table = delete_duplicate_columns(table) for row in table: if row in dict: continue dict.append(row) result[0].append(formatPhone(row[1])) result[1].append(str(bool(int(row[2].split(';')[1]))).lower()) result[2].append(formDate(*row[2].split(';')[0].split('.'))) result[3].append(row[3][row[3].find('[at]') + 4:]) return result def formDate(year, month, day): return day + '/' + month + '/' + year def formatPhone(phone): return '(' + phone[:3] + ') ' + phone[3] + phone[4] + phone[5] + '-' + phone[6] + phone[7] + '-' + phone[8] + phone[9] def delete_empty_rows(table): return [row for row in table if row is not None] def delete_duplicate_columns(table): for row in table: i = 0 key = row[2] for row2 in table: if row2[2] == key: i = i + 1 if i == 2: del row2 i = 0 return table" "def main(table): parsed = set() (surname, date_p, score, phone_p) = ([], [], [], []) for (fullname, date, percent, _, phone) in table: if fullname in parsed or fullname is None: continue parsed.add(fullname) surname.append(fullname.split()[1]) date_p.append(date.replace('.', '-')) score.append(f""{float(percent.strip('%')) / 100:.1f}"") phone_sp = phone.split() phone_p.append(f""{phone_sp[0].replace('(', '').replace(')', '')} {phone_sp[1][0:6]}{phone_sp[1][7:]}"") return [surname, date_p, score, phone_p]" "def del_space(data): delArr = [] for i in range(0, len(data)): data[i].pop(1) if data[i][0] is None: delArr.append(i) delArr.sort(reverse=True) for i in delArr: data.pop(i) return data def parse_data(data): for i in data: if i[0] == 'Да': i[0] = 'Y' elif i[0] == 'Нет': i[0] = 'N' i[1] = i[1][:-1] if len(i[1]) == 1: i[1] = '0.0' + i[1] else: i[1] = '0.' + i[1] i[1] = str(round(float(i[1]), 1)) i[2] = i[2].split('[at]')[0] return data def main(data): data = del_space(data) data = parse_data(data) return data" "import re def clear_empty_rows(table): new_table = [] for i in range(len(table)): if table[i] == [None, None, None, None]: continue else: new_table.append(table[i]) return new_table def get_row(row_data): temp_percent = float(row_data[0][:len(row_data[0]) - 1]) / 100 row_data[0] = format(temp_percent, '.2f') tpn = row_data[1].replace('(', ' ') tpn = tpn.replace(')', ' ') row_data[1] = tpn[:len(tpn) - 3] + tpn[len(tpn) - 2:] template = '\\[at\\]([a-z\\.]+)#([0-9/]+)' tm = re.findall(template, row_data[2])[0] row_data[2] = tm[0] row_data[3] = tm[1][len(tm[1]) - 4:] + tm[1][2:len(tm[1]) - 4] + tm[1][:2] return row_data def main(table): table = clear_empty_rows(table) for i in range(len(table)): table[i] = get_row(table[i]) return table" "def main(table): table = delete_empty_rows(table) dict = [] result = [[], [], []] for row in table: if row in dict: continue dict.append(row) result[0].append(formDate(*row[0].split('.'))) result[1].append(formName(*row[1].split(' '))) if row[3] == 'true' and row[3] == row[2]: result[2].append('Y') else: result[2].append('N') return result def formDate(year, month, day): return day + '-' + month + '-' + year def formName(fname, otets, sname): return sname + ', ' + fname[0] + '.' + otets def delete_empty_rows(table): return [row for row in table if row[0] is not None]" "def main(lis): n = 0 k = 0.7 name = '' name2 = '' for i in range(len(lis)): s = lis[i][0] s = s.replace('.', '-') lis[i][0] = s s = lis[i][1] name = s[0:s.find(' ')] name2 = s[s.find(' ') + 1:s.find(' ') + 3] lis[i][1] = name2 + ' ' + name s = lis[i][2] if s == 'Выполнено': lis[i][2] = 'true' else: lis[i][2] = 'false' k = float(lis[i][3]) n = round(k, 3) s = str(n) + '00' lis[i][3] = s return lis" "import re def deleteEmpty(table): result = [] for row in table: newrow = [] for ind in range(len(row)): if row[ind] is not None: newrow.append(row[ind]) if newrow != []: result.append(newrow) return result def convert(table): regex = '@(.*)' for i in range(len(table)): if table[i][0] == 'да': table[i][0] = 'Выполнено' if table[i][0] == 'нет': table[i][0] = 'Не выполнено' if table[i][1] is not None: table[i][1] = table[i][1][0] + table[i][1][1] + ' ' + table[i][1][2] + table[i][1][3] + table[i][1][4] + ' ' + table[i][1][5] + table[i][1][6] + table[i][1][7] + '-' + table[i][1][8] + table[i][1][9] + '-' + table[i][1][10] + table[i][1][11] if table[i][2] is not None: while len(table[i][2]) < 6: table[i][2] = table[i][2] + '0' if table[i][3] is not None: table[i][3] = re.findall(regex, table[i][3])[0] return table def main(table): return convert(deleteEmpty(table))" "def erase_cols(table): for row in table: del row[0] return table def erase_rows(table): for i in range(len(table)): if table[i][0] is None: del table[i] break return table def transform(table): for row in table: row[0] = row[0][:2] + '/' + row[0][3:5] + '/' + row[0][8:] if row[1] == 'да': row[1] = 'true' else: row[1] = 'false' row[2] = row[2][row[2].find(',') + 2:row[2].find(',') + 4] + ' ' + row[2][:row[2].find(',')] return table def main(table): return transform(erase_rows(erase_cols(table)))" "def delete_doubles_columns(data): columns_to_delete = [] for str in data: for el1 in range(len(str)): for el2 in range(el1, len(str)): if not el1 == el2: if str[el1] == str[el2]: if el2 not in columns_to_delete: columns_to_delete.append(el2) for j in columns_to_delete: for i in range(len(data)): _ = data[i].pop(j) return data def del_empty(table): temp = [] temp_row = [] for i in table: for j in i: if j is not None: temp_row.append(j) temp.append(temp_row) temp_row = [] return temp def emails(table): temp = table for i in range(len(temp)): for j in range(len(temp[i])): if temp[i][j] is not None and temp[i][j].find('[at]') != -1: temp[i][j] = table[i][j].replace('[at]', '@') return temp def date_reformat(data_): data = data_ for i in range(len(data)): for j in range(len(data[i])): if data[i][j] is not None and data[i][j].find('/') != -1: data[i][j] = data[i][j].replace('/', '.') return data def transp(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def transformer(i, value): if i == 1: name = value.split() return f'{name[1]}' if i == 3: val = value[len(value) - 9:len(value)] val = val[:6] + val[7:] return f'{val}' else: return value def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transp(date_reformat(emails(delete_doubles_columns(del_empty(transform(table))))))" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate(list): dup_free = [] for i in range(len(list)): if list[i] not in dup_free: dup_free.append(list[i]) return dup_free def delete_duplicate_columns(table): for row in table: del row[2] del row[3] return table def toFixed(numObj, digits=0): return f'{numObj:.{digits}f}' def transform(table): l0 = [] l1 = [] l2 = [] buff = '' for lemm in table[0]: l0.append(lemm[-2:] + '/' + lemm[5:7] + '/' + lemm[2:4]) for lemm in table[1]: for i in range(len(lemm)): if lemm[i] == '%': l1.append(toFixed(float(buff) / 100, 1)) l2.append(lemm[i + 2:-2].replace(',', '')) buff = '' break buff += lemm[i] table[0] = l0 table[1] = l1 table.append(l2) return table def main(table): return transform(delete_empty_rows(delete_duplicate(transpose(delete_duplicate(delete_empty_rows(table))))))" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('/') i[n] = f'{hop[0]}.{hop[1]}.{hop[2]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('Выполнено', 'да') i[n] = i[n].replace('Не выполнено', 'нет') return lst def format_procent(lst, n): for i in lst: j = round(float(i[n]), 2) * 100 i[n] = str(int(j)) + '%' return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = j[0] + ' ' + j[2] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][6:] i[n] = i[n].replace('-', '') return lst def email_format(lst, n): for i in lst: i[n] = i[n].replace('@', '[at]') return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = splt(lst, 2, 2, sep='!') lst = format_data(lst, 2) lst = true_format(lst, 3) lst = surname_format(lst, 1) lst = telephone_format(lst, 0) lst = transpose(lst) return lst" "def main(a: list): i = len(a) - 1 while i >= 0: if a.count(a[i]) > 1: del a[i] else: a[i][0] = 'Y' if a[i][0] == 'true' else 'N' a[i][1] = a[i][1][3:6] + ' ' + a[i][1][7:13] + a[i][1][-2:] name = a[i][2].split(' ') a[i][2] = name[2] + ' ' + name[0][:1] + '.' + name[1] i -= 1 a.sort(key=lambda name: name[2]) return a" "def main(table): table = dupremove(table) ret = [] for i in range(len(table)): ret_app = [] ret_app.append(table[i][0].split('#')[1].split(' ')[0]) ret_app.append(phone(table[i][0].split('#')[0])) ret_app.append(data(table[i][1])) ret.append(ret_app) return [list(x) for x in zip(*ret)] def dupremove(ls): res = [] for i in ls: if i not in res: res.append(i) return res def phone(str): return str[0] + str[1] + ' ' + str[2] + str[3] + str[4] + ' ' + str[5] + str[6] + str[7] + '-' + str[8] + str[9] + str[10] + str[11] def data(str): return str[8] + str[9] + '/' + str[5] + str[6] + '/' + str[2] + str[3]" "def empty_cols(table): for row in table: del row[0] del row[1] return table def transform(table): for row in table: row[0] = row[0][row[0].find(']') + 1:] if row[1] == 'Выполнено': row[1] = 'true' else: row[1] = 'false' row[2] = row[2][:2] + ' ' + row[2][2:7] + ' ' + row[2][7:] return table def trans(table): trans = [] for i in range(3): trans.append([]) for j in range(len(table)): trans[i].append(table[j][i]) return trans def main(table): return trans(transform(empty_cols(table)))" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): for row in table: del row[1] return table def transformer(i, value): if i == 0: start = value.find(']') replaced = value[start:len(value)] return replaced[1:] if i == 1: dig = value[4:7] + value[8:12] return dig if i == 2: ret = value[0:value.find('.') - 1] + value[value.find('.') + 2:len(value)] return ret def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_duplicate_columns(delete_empty_rows(table))))" "def f(lul): n = [] for i in lul: if i not in n and i[0] is not None: n.append(i) return n def trans(matrix): trans_matrix = [[0 for j in range(len(matrix))] for i in range(len(matrix[0]))] for i in range(len(matrix)): for j in range(len(matrix[0])): trans_matrix[j][i] = matrix[i][j] return trans_matrix def main(matrix): matrix = f(matrix) trans_matrix = trans(matrix) trans_matrix = f(trans_matrix) for j in range(len(trans_matrix[0])): trans_matrix[0][j] = trans_matrix[0][j][0:2] + ' ' + trans_matrix[0][j][2:5] + ' ' + trans_matrix[0][j][5:8] + '-' + trans_matrix[0][j][8:] trans_matrix[1][j] = trans_matrix[1][j].replace('Y', 'Выполнено') trans_matrix[1][j] = trans_matrix[1][j].replace('N', 'Не выполнено') trans_matrix[2][j] = trans_matrix[2][j].split('@')[1] return trans_matrix" "def step1(table): i_len = len(table) for i in range(i_len): if table[i][0] is None: del table[i][0] def step1_2(table): for i in range(len(table)): name = table[i][1] table[i][0] = name def step2(table): temp = [] for x in table: if x not in temp: temp.append(x) return temp def step3(table): for i in range(len(table)): (a, b) = table[i][2].split(';') table[i][1] = b table[i].insert(2, a) for i in range(len(table)): del table[i][3] def step4(table): for i in range(len(table)): table[i][0] = table[i][0][:-2] table[i][1] = table[i][1].replace('Не выполнено', 'false') table[i][1] = table[i][1].replace('Выполнено', 'true') table[i][2] = table[i][2][:0] + '(' + table[i][2] table[i][2] = table[i][2][:4] + ') ' + table[i][2][5:] table[i][2] = table[i][2][:12] + '-' + table[i][2][12:] def main(table): step1(table) step1_2(table) table = step2(table) step3(table) step4(table) return table" "def main(x): s = [] res = [] for i in range(len(x)): if not x[i] in res: res.append(x[i]) for i in range(len(res)): if res[i][0] is None: continue s.append([]) j = 0 for i in range(len(res)): if res[i][0] is None: continue s[j].append(res[i][0].split('/')[2].split('#')[0] + '.' + res[i][0].split('/')[1] + '.' + res[i][0].split('/')[0]) s[j].append(str(round(float(res[i][0].split('/')[2].split('#')[1]) * 100)) + '%') s[j].append(res[i][1].split('@')[1]) j = j + 1 return s" "def main(table: list) -> list: index = 0 seen = set() while index < len(table): if tuple(table[index]) in seen: del table[index] else: seen.add(tuple(table[index])) index += 1 for (n_line, line) in enumerate(table): for (n_column, column) in enumerate(line): if column.find('#') != -1: line.pop(n_column) line.insert(n_column, column.split('#')[0]) line.insert(n_column + 1, column.split('#')[1]) for line in table: line[0] = f'{line[0][-2:]}/{line[0][5:7]}/{line[0][2:4]}' line[1] = f""{line[1].split('@')[0]}"" line[2] = 'Да' if int(line[2]) else 'Нет' (line[1], line[2]) = (line[2], line[1]) return list(map(list, zip(*table)))" "def delete_empty_columns(table): iLen = len(table) for i in range(iLen): if table[i][0] is None: del table[i][0] return table def delete_duplicate_columns(table): iLen = len(table) for i in range(iLen): del table[i][2] return table def transformer(j, value): if j == 0: return f'{float(value):.3f}' if j == 1: res = [] res.append(value[6]) res.append(value[7]) res.append('.') res.append(value[3]) res.append(value[4]) res.append('.') res.append(value[0]) res.append(value[1]) res_str = ''.join(res) return res_str if j == 2: if value == '0': return 'нет' if value == '1': return 'да' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(delete_duplicate_columns(delete_empty_columns(table)))" "def empty_cols(table): for row in table: del row[1] del row[1] return table def same_rows(table): i = 0 while i < len(table): j = i + 1 while j < len(table): if table[i][0] == table[j][0]: del table[j] j -= 1 j += 1 i += 1 return table def empty_rows(table): for i in range(len(table)): if table[i][0] is None: del table[i] break return table def variant(table): for row in table: row[0] = row[0][2:4] + '-' + row[0][5:7] + '-' + row[0][8:] row[1] = row[1][:2] + '(' + row[1][3:6] + ')' + row[1][7:13] + '-' + row[1][13:] row[2] = row[2][:row[2].find(' ') + 1] + row[2][row[2].find('.') + 2:] return table def main(table): return variant(empty_rows(same_rows(empty_cols(table))))" "def main(table): parsed = [] parsed1 = [] for row in table: for column in row: if column is not None: if '!' in column: a = ''.join(column.split('!')[1].split('+7', 1)[1]) b = a[0:3] + '-' + a[3:6] + '-' + a[6:10] parsed1.append(b) parsed1.append(column.split('!')[0].split('@')[0]) continue if '0.' in column: s1 = round(float(column), 2) s2 = '%.2f' % s1 parsed1.append(s2) if ' ' in column: parsed1.append(column.split(' ')[1]) parsed.append(parsed1) parsed1 = [] parsed2 = list(filter(lambda x: x, parsed)) parsed3 = [] for row in parsed2: if row not in parsed3: parsed3.append(row) return parsed3" "def main(table): for row in table: row[0] = str('{0:.2f}'.format(float(row[0]))) if row[1] == 'N': row[1] = 'Нет' else: row[1] = 'Да' (numb, date) = row[2].split('!') numb = refactor_numb(numb) date = refactor_date(date) row[2] = numb row[3] = date res = [] for row in table: if row not in res: res.append(row) return res def refactor_numb(nom): return nom[0:2] + ' ' + nom[2:5] + ' ' + nom[5:8] + '-' + nom[8:] def refactor_date(dateq): return dateq.replace('-', '/')" "def main(a: list): for i in range(len(a)): del a[i][2] del a[i][2] name = a[i][0].split(' ') a[i][0] = name[1] + ' ' + name[0] a[i][1] = '1' if a[i][1] == 'да' else '0' a[i][2] = a[i][2][-4:] a.sort(key=lambda name: name[0]) res = [[], [], []] for i in range(3): for j in range(len(a)): res[i].append(a[j][i]) return res" "def main(x): result = [] for row in x: mail = row[0] phone = row[1] date = row[3] mail = mail.replace('[at]', '@') phone = phone[6:9] + phone[9:12] + phone[13:] date = date.replace('.', '/') resultt = [] resultt.append(mail) resultt.append(phone) resultt.append(date) result.append(resultt) result = list(map(list, zip(*result))) return result" "def main(o): def deletenone(u): k = [] for i in u: if i is not None: k.append(i) return k def newcolumn(v): f = [] for i in v: if ';' in i: a = i.split(';') a[0] += '0' f.append(a[1]) f.append(a[0]) else: f.append(i) return f def deletedog(g): for i in range(0, len(g)): if '@' in g[i]: b = g[i].split('@') g[i] = b[0] return g def replacesome(h): q = h[0] h[0] = q[8] + q[9] + '/' + q[5] + q[6] + '/' + q[0:4] return h for j in range(0, len(o)): o[j] = deletenone(o[j]) for j in range(0, len(o)): o[j] = newcolumn(o[j]) for j in range(0, len(o)): o[j] = deletedog(o[j]) for j in range(0, len(o)): o[j] = replacesome(o[j]) return o" "def remove_col(old_table): new_table = [] for row in old_table: new_table.append(row[0:2]) return new_table def remove_row_double(table): new_table = [] for row in table: if row not in new_table: new_table.append(row) return new_table def split_row(table): new_table = [] for row in table: new_row = row[0].split('#') (new_row[0], new_row[1]) = (new_row[1], new_row[0]) new_row.append(row[1]) new_table.append(new_row) return new_table def change_row(table): new_table = [] for row in table: new_row = [] new_row.append(str(round(float(row[0]) * 100)) + '%') new_row.append(row[1].replace('.', '-')) new_row.append(row[2][:-2]) new_table.append(new_row) return new_table def transpose(table): return list(map(list, zip(*table))) def main(h): return transpose(change_row(split_row(remove_row_double(remove_col(h)))))" "def main(table): return transpose(sort_table(tranform(split_date(delete_duplicate_rows(delete_duplicate_columns(table)))))) def delete_duplicate_columns(table): for i in range(len(table)): for j in range(0, len(table[i])): repeat = j + 1 while repeat < len(table[i]): if table[i][j] == table[i][repeat]: table[i].pop(repeat) else: repeat += 1 return table def delete_duplicate_rows(table): for rows in range(len(table)): repeat = rows + 1 while repeat < len(table): if table[rows][0] == table[repeat][0]: table.pop(repeat) else: repeat += 1 return table def split_date(table): for row in table: row[0] = row[0].split('|') row.insert(0, row[0][0]) row.insert(1, row[1][1]) row.pop(2) return table def tranform(table): for row in table: datesplit = row[0].split('.') row[0] = datesplit[2][2:] + '.' + datesplit[1] + '.' + datesplit[0] row[1] = str(round(float(row[1]), 3)) while len(row[1]) < 5: row[1] += '0' reverse = row[2].split(' ') row[2] = reverse[1] + ' ' + reverse[0] return table def sort_table(table): return sorted(table) def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response" "def main(table): for row in table: del row[1] del row[1] for row in table: (yn, num) = row[0].split('|') yn = yn[7:] row.insert(0, yn) row[1] = '' row[1] = '/'.join(num.split('.')[::-1]) if row[2] == 'Выполнено': row[2] = 'да' else: row[2] = 'нет' table = list(map(list, zip(*table))) (table[1], table[2]) = (table[2], table[1]) return table" "def del_dup_none(list): dup_free = [] for i in range(len(list)): if list[i][0] is not None and list[i] not in dup_free: dup_free.append(list[i]) return dup_free def count(list): for j in range(len(list)): str = list[j][1] s = '' if str[2] != '0': s += str[2] s += str[3] s += '%' list[j][1] = s return list def name(list): j = 0 for j in range(len(list)): str = list[j][0] i = 0 i = str.find(';', i) + 1 s = '' while str[i] != '[': s += str[i] i += 1 list[j][2] = s return list def date(list): for j in range(len(list)): str = list[j][0] s = '' s += str[6] s += str[7] s += str[8] s += str[9] list[j][0] = s return list def sort(list): list = sorted(list, key=lambda l: l[2]) return list def main(list): return sort(date(count(name(del_dup_none(list)))))" "def main(table): newTable = [[], [], []] dubles = [] for row in table: if row in dubles or row[0] is None: continue dubles.append(row) tempRow0 = row[0].replace(' ', '') tempRow0 = tempRow0[1:4] + '-' + tempRow0[5:] newTable[0].append(tempRow0) newTable[1].append(row[1][2:]) row3 = row[3].split('.') newTable[2].append(row3[0] + '.' + row3[2]) return newTable" "def main(table): table = list(map(list, zip(*table))) new_table = list() for row in table: if row not in new_table: new_table.append(row) table = new_table table = list(map(list, zip(*table))) for row in table: if None in row: table.remove(row) d = {'1': 'Выполнено', '0': 'Не выполнено'} for row in table: row[0] = ' '.join(row[0].split('-', maxsplit=1)) row[1] = '.'.join(row[1].split('/')[::-1]) row[2] = d[row[2]] row[3] = str(round(float(row[3]) * 100)) + '%' table.sort(key=lambda row_t: row_t[0]) table = list(map(list, zip(*table))) return table" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('/') i[n] = f'{hop[0]}.{hop[1]}.{hop[2]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('Выполнено', 'да') i[n] = i[n].replace('Не выполнено', 'нет') return lst def format_procent(lst, n): for i in lst: j = round(float(i[n]), 2) * 100 i[n] = str(int(j)) + '%' return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = j[2] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n].replace('(', '') i[n] = i[n].replace(')', '') i[n] = i[n][3:13] + i[n][14:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].replace('@', '[at]') return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = email_format(lst, 0) lst = surname_format(lst, 1) lst = telephone_format(lst, 2) lst = transpose(lst) return lst" "def main(table): for row in table: del row[2] new_table = list() for row in table: if row not in new_table: new_table.append(row) table = new_table for row in table: (full_name, status) = row[0].split(';') if status == '0': status = 'Не выполнено' else: status = 'Выполнено' row[0] = status row[1] = str(int(row[1].split('-')[0])) (surname, initials) = full_name.split(' ') row.insert(2, ' '.join((initials[:2], surname))) row[3] = str(round(int(row[3].split('%')[0]) / 100, 1)) table = list(map(list, zip(*table))) return table" "def repeated_s(x): i = 0 while i < len(x): j = i + 1 while j < len(x): if x[i] == x[j]: del x[j] j -= 1 j += 1 i += 1 return x def separate(x): for s in x: s.append(s[1][s[1].find('&') + 1:]) s[1] = s[1][:s[1].find('&')] return x def vari(x): for s in x: s[0] = str(round(float(s[0]), 3)) if len(s[0]) == 4: s[0] += '0' if s[2] == 'да': s[2] = 'true' else: s[2] = 'false' s[1] = s[1][2:4] + '/' + s[1][5:7] + '/' + s[1][8:] (s[1], s[2]) = (s[2], s[1]) return x def main(x): return vari(separate(repeated_s(x)))" "def normalize(table): for i in range(len(table)): phone = table[i][0].split('&')[1][3:] name = table[i][0].split('&')[0].split() email = table[i][1].split('[')[0] reversed_name = name[1] + ' ' + name[0] table[i][0] = reversed_name table[i][1] = email table[i][2] = phone return table def sort(table): table.sort(key=lambda x: x[1]) return table def transpose(m): return [[m[j][i] for j in range(len(m))] for i in range(len(m[0]))] def main(table): return transpose(sort(normalize(table)))" "def main(table): parsed = set() (fullname_p, date_p, phone_p) = ([], [], []) for (fullname, _, date, phone) in table: if fullname in parsed or fullname is None: continue parsed.add(fullname) fullname_p.append(fullname[:-2]) date_sp = date.split('-') date_p.append(f'{date_sp[2]}.{date_sp[1]}.{date_sp[0]}') phone_p.append(phone.replace(' ', '-')) return [fullname_p, date_p, phone_p]" "def main(table): tmp_tb = [] for y in table: if y[0] is not None: t = [] for x in y: if x is not None: t.append(x) tmp_tb.append(t) for i in range(len(tmp_tb)): date = '(' + tmp_tb[i][0][0:3] + ') ' + tmp_tb[i][0][4:10] + '-' + tmp_tb[i][0][10:] tmp_tb[i][0] = date tmp_tb[i][1] = tmp_tb[i][1].replace('.', '/') date = tmp_tb[i][1][8:] + tmp_tb[i][1][4:7] + '/' + tmp_tb[i][1][2:4] tmp_tb[i][1] = date tmp_tb[i][3] = tmp_tb[i][3].replace(';', ' ') string = tmp_tb[i][3].split(' ') date = string[1] + ' ' + string[3] tmp_tb[i][2] = date date = string[0] tmp_tb[i][3] = date if tmp_tb[i][3] == '0': tmp_tb[i][3] = 'Не выполнено' else: tmp_tb[i][3] = 'Выполнено' n = [] for i in tmp_tb: if i not in n: n.append(i) return n" "import re def delStr(mas): for i in range(len(mas) - 1): for o in range(i + 1, len(mas)): if mas[i] == mas[o]: mas.pop(o) delStr(mas) break def delStolb(mas): for i in range(len(mas[0]) - 1): for o in range(i + 1, len(mas[0])): if mas[0][i] == mas[0][o]: for с in range(len(mas)): mas[с].pop(o) break def delForm(mas): for i in range(len(mas)): mas[i][0] = re.sub('.\\.( )', ' ', mas[i][0]) mascifr = re.findall('(\\d*)-(\\d*)-(\\d*)', mas[i][1]) mas[i][1] = mascifr[0][2] + '-' + mascifr[0][1] + '-' + mascifr[0][0] mas[i][2] = re.sub('\\w*\\[at\\]', '', mas[i][2]) mas[i][3] = mas[i][3].replace('да', '1') mas[i][3] = mas[i][3].replace('нет', '0') def main(mas): delStr(mas) delStolb(mas) delForm(mas) mas = sorted(mas, key=lambda x: x[0]) return mas" "def kal(m): for j in m: m.reverse() while m.count(j) > 1: m.remove(j) m.reverse() if j == 'Y': m[m.index(j)] = 'да' if j == 'N': m[m.index(j)] = 'нет' if len(j) == 5: m[m.index(j)] = str(int(round(round(float(m[m.index(j)]), 2) * 100))) + '%' if len(j) == 8: m[m.index(j)] = j[6:] + '/' + j[3:5] + '/' + j[0:2] if '. ' in j: m[m.index(j)] = j[5:] return m def main(t): k = 0 for i in t: t.reverse() while t.count(i) > 1: t.remove(i) t.reverse() while t[k].count(None) > 0: t[k].remove(None) kal(t[k]) k = k + 1 for i in t: if len(i) == 0: t.remove(i) trans = [[0 for j in range(len(t))] for i in range(len(t[0]))] for i in range(len(t)): for j in range(len(t[0])): trans[j][i] = t[i][j] return trans" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[0] i.insert(a, s[1]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('.') i[n] = f'{hop[2]}-{hop[1]}-{hop[0]}' return lst def format_procent(lst, n): for i in lst: j = round(float(i[n]), 2) * 100 i[n] = str(int(j)) + '%' return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = j[2] return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('1', 'Выполнено') i[n] = i[n].replace('0', 'Не выполнено') return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][9:15] + i[n][16:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].replace('@', '[at]') return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = splt(lst, 0, 2, sep=';') lst = format_data(lst, 1) lst = true_format(lst, 2) lst = telephone_format(lst, 0) lst = transpose(lst) return lst" "def main(a: list): res = [[], [], [], []] for i in range(len(a)): cell = a[i][0].split(';') name = a[i][5].split(' ') res[0].append(cell[0][:cell[0].find('@')]) res[1].append(a[i][2].replace('-', '/')) res[2].append(name[2] + ', ' + name[0][:1] + '.' + name[1]) res[3].append('%.2f' % round(float(cell[1]), 2)) return res" "def main(table): parsed = set() (fullname_p, phone, score_r, res) = ([], [], [], []) for (fullname, data, score) in table: if fullname in parsed or fullname is None: continue parsed.add(fullname) data_s = data.split('|') fullname_s = fullname.split() phone_s = data_s[1].split() fullname_p.append(f'{fullname_s[2]} {fullname_s[0][0]}.{fullname_s[1]}') phone.append(f""{phone_s[0]} {phone_s[1].replace('(', '').replace(')', '')} {phone_s[2][0:6]}{phone_s[2][7:]}"") score_r.append(f'{round(float(score), 1)}') res.append('Y' if data_s[0] == 'Выполнено' else 'N') return [fullname_p, phone, score_r, res]" "def del_none(list): dup_free = [] for i in range(len(list)): if list[i][0] is not None: dup_free.append(list[i]) return dup_free def count(list): for j in range(len(list)): str = list[j][0] i = 0 i = str.find(';', i) + 1 s = '' while i < len(str): s += str[i] i += 1 s += '00' list[j][0] = s return list def name(list): j = 0 for j in range(len(list)): str = list[j][2] i = 0 i = str.find(' ', i) + 1 s = '' while i < len(str): s += str[i] i += 1 list[j][2] = s return list def date(list): for j in range(len(list)): str = list[j][0] s = '' s += str[6] s += str[7] s += '/' s += str[3] s += str[4] s += '/' s += str[0] s += str[1] list[j][1] = s return list def transform(mat): L = [] for i in range(3): L.append(list()) for j in range(len(mat)): L[i].append(mat[j][i]) return L def main(list): return transform(name(count(date(del_none(list)))))" "import re def delete_duplocate(table): for i in range(len(table)): table[i].pop(3) return table def delete_empthy(table): for i in range(len(table)): table[i].pop(2) return table def replace_yn(table): for i in range(len(table)): table[i][0] = table[i][0].replace('Y', 'да') table[i][0] = table[i][0].replace('N', 'нет') return table def digit(table): for i in range(len(table)): number = float(table[i][2]) number = round(number, 1) table[i][2] = str(number) return table def main(table): delete_duplocate(table) delete_empthy(table) for i in range(len(table)): mascifr = re.findall('(\\d*)\\/(\\d*)\\/(\\d*)', table[i][1]) table[i][1] = mascifr[0][2] + '.' + mascifr[0][1] + '.' + mascifr[0][0] replace_yn(table) digit(table) return table" "import re def delete_empty_columns(table): for i in range(len(table)): table[i].pop(3) def duplicate_columns(table): for i in range(len(table)): table[i].pop(3) def calendar_plus(table): for i in range(len(table)): mas = [] mas = table[i][2].split(';') table[i][1] = mas[0] table[i][2] = mas[1] return table def replace_yn(table): for i in range(len(table)): table[i][3] = table[i][3].replace('да', '1') table[i][3] = table[i][3].replace('нет', '0') def replace_cifri(table): for i in range(len(table)): mascifr = re.findall('(\\d*)-(\\d*)-(\\d*)', table[i][1]) table[i][1] = mascifr[0][2] + '-' + mascifr[0][1] + '-' + mascifr[0][0] def replace_elementy_spiska(table): for i in range(len(table)): a = table[i][2] table[i][2] = table[i][3] table[i][3] = a def replace_imena(table): for i in range(len(table)): mascifr = re.findall('(.)\\S*\\s(.\\.) (\\S*)', table[i][0]) table[i][0] = mascifr[0][2] + ', ' + mascifr[0][0] + '.' + mascifr[0][1] def okruglenie_elementa(table): for i in range(len(table)): table[i][3] = float(table[i][3]) table[i][3] = round(table[i][3], 1) table[i][3] = str(table[i][3]) def main(table): calendar_plus(table) delete_empty_columns(table) duplicate_columns(table) replace_yn(table) replace_cifri(table) replace_elementy_spiska(table) replace_imena(table) okruglenie_elementa(table) return table" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_columns(table): return [row for row in table if row[0] is not None] def transformer(i, value): if i == 0: replaced = value.replace('.', '-') names = value.split('.') return f'{names[2]}-{names[1]}-{names[0]}' if i == 1: name = value.split() return f'{name[1]} {name[0]}' if i == 2: replaced = value return replaced[4:] def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transpose(sorted(transpose(transform(delete_empty_columns(transpose(table)))), key=lambda age: age[2]))" "def main(y): dat = [] dat1 = [] mail = [] number = [] fio = [] date = [] result = [] for i in y: if i not in dat1: dat1.append(i) for i in dat1: dat2 = [] for j in i: if j is not None: dat2.append(j) if len(dat2) != 0: dat.append(dat2) for i in dat: mail1 = i[0].split('[at]')[0] mail.append(mail1) if i[1] == 'Y': number1 = '1' else: number1 = '0' number.append(number1) fio1 = i[2].split() fio2 = fio1[0] fio1 = fio1[2] + ' ' + fio2[0] + '.' + fio1[1] fio.append(fio1) date.append(i[3].replace('/', '-')) result.append(mail) result.append(number) result.append(fio) result.append(date) return result" "def main(lst): new_lst = rep(lst) var1 = [] var2 = [] for i in range(len(new_lst)): if new_lst[i][0] is not None: new_lst[i][0] = new_lst[i][0].split(';') var1 = new_lst[i][0][0].replace('.', '/') var2 = new_lst[i][0][1] new_lst[i].insert(0, var1) new_lst[i].insert(1, var2) new_lst[i].pop(2) new_lst = rep(list(map(list, zip(*new_lst)))) for i in range(len(new_lst[1])): if new_lst[1][i] is not None: new_lst[1][i] = new_lst[1][i][7:] t1 = new_lst[0] t2 = new_lst[2] new_lst[0] = new_lst[1] new_lst[1] = t2 new_lst[2] = t1 for i in range(len(new_lst[1])): if new_lst[1][i] is not None: new_lst[1][i] = round(float(new_lst[1][i]), 2) new_lst[1][i] = int(round(new_lst[1][i] * 10, 1) * 10) new_lst[1][i] = str(new_lst[1][i]) + '%' for i in range(len(new_lst[2])): if new_lst[2][i] is not None: new_lst[2][i] = new_lst[2][i].split('/') new_lst[2][i] = new_lst[2][i][2][2:] + '/' + new_lst[2][i][1] + '/' + new_lst[2][i][0] new_lst = rep(list(map(list, zip(*new_lst)))) return new_lst def around(x, y=0): m = int('1' + '0' * y) q = x * m c = int(q) i = int((q - c) * 10) if i >= 5: c += 1 return c / m def rep(lst): n = [] for i in lst: if i not in n: n.append(i) return n" "def main(a: list): i = len(a) - 1 while i >= 0: if a.count(a[i]) > 1 or a[i][1] is None: del a[i] else: del a[i][0] date = a[i][0].split('/') name = a[i][3].split(' ') a[i][0] = date[2] + '-' + date[1] + '-' + date[0] a[i][1] = a[i][1][:a[i][1].find('[')] a[i][2] = '1' if a[i][2] == 'Да' else '0' a[i][3] = name[1][:2] + ' ' + name[0][:-1] i -= 1 a.sort(key=lambda name: name[3]) return a" "from operator import itemgetter from pprint import pprint def f(lst): n = [] for i in lst: if i not in n and (not None): n.append(i) return n def main(data: list): for i in range(len(data)): data[i] = list(filter(None, data[i])) data = list(filter(None, data)) for i in range(len(data)): if data[i][2]: a = data[i][2].split(';') data[i].pop() data[i].extend(a) if data[i][0] == 'нет': data[i][0] = 'Не выполнено' if data[i][0] == 'да': data[i][0] = 'Выполнено' if data[i][1]: data[i][1] = data[i][1] + '0' if data[i][2]: data[i][2] = data[i][2].replace('/', '-') if data[i][3]: b = list(data[i][3]) b.pop() b.pop() data[i][3] = ''.join(b) one = [] two = [] three = [] four = [] newdata = [] for item in data: one.append(item[0]) two.append(item[1]) three.append(item[2]) four.append(item[3]) newdata.append(one) newdata.append(two) newdata.append(three) newdata.append(four) return newdata data = [[None, 'нет', '0.936', '2002/02/06;Везозко Я.Ц.'], [None, None, None, None], [None, 'нет', '0.672', '2001/07/19;Цимофов А.Е.'], [None, 'нет', '0.884', '2002/03/10;Самский А.И.']] main(data)" "def main(table): parsed = set() (phone, date_p, res, score_r) = ([], [], [], []) for (data, date, _, score) in table: if data in parsed or data is None: continue parsed.add(data) data_s = data.split('!') date_s = date.split('-') phone.append(f'({data_s[0][2:5]}) {data_s[0][5:8]}-{data_s[0][8:10]}-{data_s[0][10:]}') date_p.append(f'{date_s[2]}/{date_s[1]}/{date_s[0]}') res.append('true' if data_s[1] == 'Y' else 'false') score_r.append(f'{score}0') return [phone, date_p, res, score_r]" "def delete_empty(table): new_table = [] for i in table: list = [x for x in i if x is not None] if list: new_table.append(list) return new_table def delete(table): new_table = [] index = 0 for i in table: for j in i: if i.count(j) > 1: i.remove(j) new_table.append(i) return new_table def transmation_data(table): new_table = [] for i in table: list = [] for j in range(0, len(i), 1): if j == 0: st = i[j][7:len(str(i[j]))] st = i[j][7:len(str(i[j]))][0:4] + st[4:len(st)].replace('-', '') list.append(st) if j == 1: st = str(i[j]).replace(',', '') st2 = '' for k in range(0, st.index(' '), 1): st2 += st[k] st = st[len(st) - 4:len(st) - 2] + ' ' + st2 list.append(st) if j == 2: st = str(i[j])[0:len(i[j]) - 1] st = str(float(st) / 100) + '00' if len(st) < 6: st += '0' list.append(st) if j == 3: st = str(i[j])[6:10] + '/' st += str(i[j])[3:5] + '/' st += str(i[j])[0:2] list.append(st) new_table.append(list) return new_table def tr_matrix(table): return list(map(list, zip(*table))) def main(h): return tr_matrix(transmation_data(delete(delete_empty(h))))" "def transform(lst): for ln in lst: ln[0] = transform_bool(ln[0]) ln[1] = transform_num(ln[1]) ln[2] = transform_name(ln[2]) ln[3] = transform_email(ln[3]) return lst def transform_bool(ele): ele = ele.replace('0', 'false') ele = ele.replace('1', 'true') return ele def transform_num(ele): ele = ele.removeprefix('+7 ') i = ele.rfind('-') ele = ele[:i] + ele[i + 1:] return ele def transform_name(ele): ele = ele.split(' ') return ele[1][0] + ele[1][1] + ' ' + ele[0] def transform_email(ele): ele = ele.split('[at]') return ele[1] def main(args): return transform(args)" "def main(table): parsed = set() (percent, phone_p, email_p) = ([], [], []) for (score, _, _, phone, _, email) in table: if email in parsed or email is None: continue parsed.add(email) percent.append(f'{round(float(score) * 100)}%') phone_s = phone.split('-') phone_p.append(f'{phone_s[1]}{phone_s[2]}') email_p.append(email.replace('@', '[at]')) return [percent, phone_p, email_p]" "def main(nbook): n2 = [] for i in nbook: if i not in n2 and i[0] is not None: n2.append(i) n3 = [] for i in range(0, len(n2)): if n2[i][0] == 'Выполнено': n2[i][0] = '1' else: n2[i][0] = '0' stroka = n2[i][3] stroka = stroka.split('@') email = stroka[1] n2[i][2] = n2[i][2] + '00' stroka2 = n2[i][3].split('!') stroka0 = stroka2[0] stroka0 = stroka0.split('-') stroka0[0] = '(' + stroka0[0] + ')' stroka0 = stroka0[0] + ' ' + stroka0[1] + '-' + stroka0[2] n3.append([n2[i][0], n2[i][2], email, stroka0]) nbook = [] for i in range(0, len(n3[0])): stroka = [] for j in range(len(n3)): stroka.append(n3[j][i]) nbook.append(stroka) return nbook" "def main(matrix): matrix = list(map(list, zip(*matrix))) for i in matrix: if matrix.count(i) > 1: matrix.remove(i) if i.count(None): matrix.remove(i) arr = [] for i in range(len(matrix)): for j in range(len(matrix[i])): if ':' in matrix[i][j]: arr.append(round(float(matrix[i][j].split(':')[0]), 2)) matrix[i][j] = matrix[i][j].split(':')[1] matrix[i][j] = matrix[i][j].replace('@', '[at]') matrix[i][j] = matrix[i][j].split(',')[0] if i == 2: ar = matrix[i][j].split('/') (ar[0], ar[2]) = (ar[2], ar[0]) matrix[i][j] = '/'.join(ar) for i in range(len(arr)): arr[i] = str(arr[i]) if len(arr[i]) == 3: arr[i] = arr[i] + '0' matrix.insert(2, arr) return matrix" "def delete_duplicate_columns(table): for row in table: row[2] = '' return table def delete_duplicate_rows(table): dup_free = [] dup_free_set = set() for x in table: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) table = dup_free return dup_free def transformer(i, value): if i == 0: date = value.split('-') return f'{date[2]}.{date[1]}.{date[0]}' if i == 1: name = value.split(',') return f'{name[0]}' if i == 2: value = value[2:] value = f'{value[:3]} {value[3:]}' value = f'{value[:7]}-{value[7:]}' return value if i == 3: return 'Y' if value == 'Выполнено' else 'N' def separate_column(table): for i in range(len(table)): temp = table[i][3].split('&') table[i][2] = temp[0] table[i][3] = temp[1] return table def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(separate_column(delete_duplicate_rows(delete_duplicate_columns(table))))" "def main(data): for row in data: del row[row.index(None)] for i in range(len(data)): s = '#'.join(data[i]) s = s.replace('Да', 'Y').replace('Нет', 'N').replace('[at]', '@') s = s.replace(' ', '').replace('-', '') data[i] = s.split('#') for i in range(len(data[0]) + 1): for j in range(len(data)): if ';' in data[j][i]: buf = data[j][i].split(';')[1] s = data[j][i][0:data[j][i].index(';')] data[j][i] = s data[j].insert(data[j].index(data[j][i]), buf) if '+' in data[j][i]: s = data[j][i].replace(' ', '').replace('-', '') data[j][i] = s[5:] if ',' in data[j][i]: s = data[j][i].replace(',', ' ') data[j][i] = s[:-2] for i in range(len(data)): (a, b) = (data[i][len(data[i]) - 1], data[i][len(data[i]) - 2]) (data[i][len(data[i]) - 2], data[i][len(data[i]) - 1]) = (a, b) trans = list(map(list, zip(*data))) return trans" "def delete_duplicate_columns(table): for i in range(len(table)): del table[i][2] return table def delete_duplicate_rows(table): for j in range(len(table) - 1): i = j while i < len(table) - 1: i += 1 if table[j] == table[i]: del table[i] i -= 1 return table def transformer(i, value): if i == 0: data = value.split('&') number = data[1] return number[3:] if i == 1: data = value.split('.') surname = data[1] name_buf = data[0] name = name_buf[0:1] + '.' + name_buf[-1:] + '.' return surname[1:] + ', ' + name if i == 2: data = value.split('&') data1 = data[0].split('@') address = data1[0] return address def transform(table): for i in range(len(table)): table[i].append(transformer(2, table[i][0])) for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(delete_duplicate_columns(delete_duplicate_rows(table)))" "def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0]] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(-1) split = i[0].split('|') split2 = split[1].split(' ') i[0] = split2[1] i1 = i[1] if split[0] == 'Да': i[1] = 'Выполнено' else: i[1] = 'Не выполнено' i.append(i1.replace('@', '[at]')) row = [] row.append(i[2]) row.append(i[1]) row.append(i[0]) new_table.append(row) new_table.sort() for i in new_table: (i[0], i[2]) = (i[2], i[0]) return new_table" "def deleteEmptyRows(table): newTable = [] for row in table: if row[0] is not None: newTable.append(row) return newTable def transpone(table): newTable = [] for i in range(len(table[0])): newTable.append([]) for j in range(len(table)): newTable[i].append(table[j][i]) return newTable def deleteEmptyColumns(table): newTable = table newTable = transpone(newTable) newTable = deleteEmptyRows(newTable) newTable = transpone(newTable) return newTable def deleteSimilarRows(table): newTable = table for i in range(len(newTable[0])): for j in range(i + 1, len(newTable[0])): if newTable[0][i] == newTable[0][j]: for k in range(len(newTable)): newTable[k][j] = None return newTable def transform(table): newTable = table for i in range(len(newTable)): s = newTable[i][3].split(' ') newTable[i][3] = s[0] + ' (' + s[1] + ') ' + s[2][0:6] + '-' newTable[i][3] += s[2][6:8] dig = newTable[i][2].split('.') digit = int(dig[0]) + int(dig[1]) / 10 ** len(dig[1]) newTable[i][2] = str(round(digit, 1)) s = newTable[i][1].split(', ') newTable[i][1] = s[1][0] + '. ' + s[0] if newTable[i][0] == 'N': newTable[i][0] = 'Не выполнено' else: newTable[i][0] = 'Выполнено' return newTable def swap(a, b, table): for i in range(len(table[0])): buff = table[a][i] table[a][i] = table[b][i] table[b][i] = buff return table def sort(table): for i in range(len(table)): for j in range(i, len(table)): if table[i][3] > table[j][3]: table = swap(i, j, table) return table def main(table): table = deleteEmptyRows(table) table = deleteEmptyColumns(table) table = deleteSimilarRows(table) table = deleteEmptyColumns(table) table = transform(table) table = sort(table) table = transpone(table) return table" "import re def main(table): for i in range(len(table)): table[i][1] = table[i][1].split('&') table[i][0] = table[i][1][1] table[i][1] = table[i][1][0] table[i][0] = table[i][0][:6] + table[i][0][8:] table[i][0] = table[i][0][-2:] + table[i][0][2:6] + table[i][0][:2] table[i][1] = table[i][1][7:] table[i][2] = table[i][2][:-5] return reformat(table) def reformat(table): my_list_pers = [] my_list_data = [] my_list_name = [] for i in range(len(table)): my_list_pers.append(table[i][0]) my_list_data.append(table[i][1]) my_list_name.append(table[i][2]) table = [my_list_pers, my_list_data, my_list_name] return table" "def delete_empty_rows(table): return [row for row in table if row[0] is not None] def transformer(i, value): if i == 0: replaced = value.replace('#', '').replace('Y', '').replace('N', '') replaced = round(float(replaced), 2) replaced = format(replaced, '.2f') return replaced if i == 1: replaced = value.replace('(', '').replace(')', '').replace('-', '').replace(' ', '') return replaced[3:] if i == 2: replaced = value.replace('@', '[at]') return replaced if i == 3: replaced = value.replace('#', '').replace('0', '').replace('1', '').replace('2', '').replace('3', '').replace('4', '').replace('5', '').replace('6', '').replace('7', '').replace('8', '').replace('9', '').replace('.', '') if replaced == 'Y': replaced = 'true' else: replaced = 'false' return replaced def transform(table): if len(table) == 3: table2 = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]] else: table2 = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]] for i in range(len(table)): for j in range(len(table[i])): if j == 0: table2[i][j] = transformer(0, table[i][j]) table2[i][j + 1] = transformer(3, table[i][j]) else: table2[i][j + 1] = transformer(j, table[i][j]) return table2 def sortirovka(table): i = 0 for row in table: for j in range(i): if table[i][3] < table[j][3]: (table[j], table[i]) = (table[i], table[j]) j += 1 i += 1 return table def main(table): return sortirovka(transform(delete_empty_rows(table)))" "import string def main(a): res = [] for i in a: tmp = i[0].split('.') buff = tmp[0] (tmp[0], tmp[2]) = (tmp[2], tmp[0]) i[0] = '/'.join(tmp) tmp = i[1].split('.') i[1] = tmp[0] + '.' i[2] = '%.4f' % round(float(i[2]), 4) for i in a: if i not in res: res.append(i) return res" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('-') i[n] = f'{hop[0][2:]}.{hop[1]}.{hop[2]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('Выполнено', 'да') i[n] = i[n].replace('Не выполнено', 'нет') return lst def format_procent(lst, n): for i in lst: j = int(i[n][:-1]) / 100 i[n] = str(round(j, 1)) return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = f'{j[0][:1]}.{j[1]} {j[2]}' return lst def telephone_format(lst, n): for i in lst: i[n] = i[n].replace('(', '') i[n] = i[n].replace(')', '') i[n] = i[n][3:13] + i[n][14:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('[at]')[1] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = format_data(lst, 1) lst = email_format(lst, 3) lst = format_procent(lst, 0) lst = surname_format(lst, 2) lst = transpose(lst) return lst" "import re def main(table): for row in table: del row[3] new_table = list() for row in table: if row not in new_table: new_table.append(row) table = new_table for row in table: spl = re.split('@|!| ', row[0]) row[0] = spl[1] if row[1] == '1': row[1] = 'true' else: row[1] = 'false' row.append(spl[3]) row[3] = row[3].replace('-', '') for row in table: spl = row[2].split(' ') row[2] = spl[1] + ' ' + spl[0] return table" "import re def main(x): strings = [] string = [] for i in range(len(x)): string = [] if x[i][0][:2] == 'Не': string.append('0') else: string.append('1') name = str(list(str(x[i][0].split('!')[1]).split(' '))[1]) + ' ' + str(list(str(x[i][0].split('!')[1]).split(' '))[0][:2]) percent = str(round(float(x[i][1]) * 100)) + '%' mail = x[i][5].split(']')[1] string.append(name) string.append(percent) string.append(mail) strings.append(string) return strings" "def per_cent(arr): for i in range(len(arr)): arr[i][2] = str(round(float(arr[i][2]), 1)) return arr def mail(arr): for i in range(len(arr)): arr[i][1] = arr[i][1].replace('@', '[at]') return arr def date(arr): for i in range(len(arr)): new_date = arr[i][0].split('/') arr[i][0] = new_date[0] return arr def get_column(arr, index): column = [] for i in range(len(arr)): column.append(arr[i][index]) return column def transpose(arr): new_arr = [] for i in range(len(arr[0])): new_arr.append(get_column(arr, i)) return new_arr def delete_equal_lines(arr, index): result = False i = index + 1 while i < len(arr): if arr[index] == arr[i]: arr.pop(i) result = True i -= 1 i += 1 return [arr, result] def delete_none_lines(arr): i = 0 while i < len(arr): if arr[i][0] is None and arr[i][len(arr[i]) - 1] is None: arr.pop(i) i -= 1 i += 1 return arr def solve(arr): tab = transpose(arr) tab = delete_none_lines(tab) tab = transpose(tab) tab = delete_none_lines(tab) tab = date(tab) tab = mail(tab) tab = per_cent(tab) tab = transpose(tab) return tab def main(h): return solve(h)" "def main(table): parsed = set() (phone_p, date, domain) = ([], [], []) for (phone, data) in table: if data in parsed or data is None: continue parsed.add(data) data_s = data.split(':') date_s = data_s[1].split('/') phone_p.append(phone.split()[2].replace('-', '')) date.append(f'{date_s[2]}/{date_s[1]}/{date_s[0]}') domain.append(data_s[0].split('@')[1]) return [phone_p, date, domain]" "def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_rows(table): res = [] for i in table: if i not in res: res.append(i) return res def delete_duplicate_columns(table): for row in table: del row[1] return table def transformer(i, value): if i == 0: value = value[:2] + ' ' + value[2:] value = value[:6] + ' ' + value[6:] value = value[:10] + '-' + value[10:] return value if i == 1: name = value.split('#')[0].replace('/', '-') return name[2:] if i == 2: if value.split('#')[1] == 'true': return 'Да' else: return 'Нет' def transform(table): newTab = [] for i in range(len(table)): newTab.append([]) for j in range(len(table[i])): if table[i][j][0] == '+': newTab[i].append(transformer(0, table[i][j])) else: newTab[i].append(transformer(1, table[i][j])) newTab[i].append(transformer(2, table[i][j])) return newTab def main(table): return transform(delete_empty_rows(delete_duplicate_rows(delete_duplicate_columns(table))))" "import re def main(x): nums = [] percents = [] names = [] statuses = [] for i in range(len(x)): if x[i][1][7:13] + x[i][1][14:] not in nums: num = x[i][1][7:13] + x[i][1][14:] nums.append(num) percent = str(round(round(float(x[i][2]) * 100))) + '%' percents.append(percent) name = re.split(' ', x[i][4])[2] + ' ' + re.split(' ', x[i][4])[0] names.append(name) status = x[i][5].lower() statuses.append(status) return [nums, percents, names, statuses]" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('-') i[n] = f'{hop[2]}.{hop[1]}.{hop[0]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('Да', 'true') i[n] = i[n].replace('Нет', 'false') return lst def format_procent(lst, n): for i in lst: j = round(float(i[n]), 2) i[n] = '{0:.2f}'.format(j) return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = f'{j[0][:1]}.{j[1]} {j[2]}' return lst def telephone_format(lst, n): for i in lst: i[n] = i[n].replace('(', '') i[n] = i[n].replace(')', '') i[n] = i[n][3:13] + i[n][14:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('@')[0] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = format_data(lst, 3) lst = true_format(lst, 2) lst = email_format(lst, 1) lst = format_procent(lst, 0) lst = transpose(lst) return lst" "def main(lst): m = [] nm = [] for i in range(len(lst)): if lst[i] != [None, None, None]: r = str(round(int(lst[i][0].split('%')[0]) / 100, 2)) if r == '0.0': r = '0.00' nm.append(r) r1 = '@'.join(lst[i][0].split('%')[1][1:].split('[at]')) nm.append(r1) r2 = lst[i][1].title() nm.append(r2) r3 = lst[i][2].split()[0] nm.append(r3) m.append(nm) nm = [] return m" "import re def remove_extra_rows(table): new_table = [] for i in range(len(table)): if table[i] not in new_table and table[i] != [None] * len(table[i]): new_table.append(table[i]) return new_table def transpose(table): new_table = [] for i in range(len(table[0])): line = [] for j in range(len(table)): line.append(table[j][i]) new_table.append(line) return new_table def transformer(table): str = '' str1 = '' for i in range(len(table)): for j in range(len(table[i])): if i == 0: str = table[i][j] table[i][j] = str[:-2] if i == 1: str = table[i][j] str = str[3:] str1 = str[-2:] str = str[:-3] str = str + str1 table[i][j] = str if i == 2: str = table[i][j] exr = '\\[at\\]\\w+.\\w+' matches = re.findall(exr, str) str = ''.join(matches) table[i][j] = str[4:] if i == 3: str = table[i][j] table[i][j] = str + '00' return table def main(table): table = transpose(table) table = remove_extra_rows(table) table = transpose(table) table = remove_extra_rows(table) table = transpose(table) table = transformer(table) return table" "def change_list(li): li.append(li[0][li[0].index(';') + 1:li[0].index('[')] + '@' + li[0][li[0].index(']') + 1:]) li[0] = li[0][:li[0].index(';')].replace('/', '-') if len(li[1]) == 2: li[1] = '0.0' + li[1][0] + '00' elif len(li[1]) == 3: li[1] = '0.' + li[1][:2] + '00' else: li[1] = '1.0000' return li def main(old_list): li = [] for el in old_list: if el not in li: li.append(el) for i in range(len(li)): li[i] = list(filter(None, li[i])) li = list(filter(None, li)) for i in range(len(li)): li[i] = change_list(li[i]) return li" "import re reg = '\\s([А-Я]\\.\\s)' def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[1] is not None] def transform(table): table = delete_empty_rows(transpose(delete_empty_rows(table))) for i in range(len(table[0])): matches = re.findall(reg, table[0][i]) for match in matches: table[0][i] = table[0][i].replace(match, '') for i in range(len(table[1])): table[1][i] = table[1][i] + '0' for i in range(len(table[2])): if table[2][i] == 'Y': table[2][i] = 'true' if table[2][i] == 'N': table[2][i] = 'false' return table def main(table): return transform(table)" "def change_row(row): row.pop(3) row.pop(3) row[0] = row[0][:row[0].find(' ')] row[1] = row[1].replace('[at]', '@') row[2] = row[2][3:] row[3] = '.'.join(reversed(row[3].split('/'))) return row def main(table): new = [] for row in table: if row in new: continue if not any(row): continue new.append(row) for i in range(len(new)): new[i] = change_row(new[i]) new.sort(key=lambda x: x[2]) trans = [[None for _ in new] for _ in new[0]] for (i, row) in enumerate(new): for (j, cell) in enumerate(row): trans[j][i] = cell return trans" "import re def main(table): newTable = [] for i in range(len(table)): if not (table[i][0] is None and table[i][1] is None): table[i][0] = str(round(float(table[i][0]) * 100)) + '%' table[i][1] = 'Y' if table[i][1] == '1' else 'N' table[i][2] = str(table[i][2]).replace('(', '').replace(')', '') table[i][2] = table[i][2][:10] + table[i][2][11:] table[i][4] = str(re.findall('.*\\[', table[i][4])) table[i][4] = table[i][4].replace('[', '') table[i][4] = table[i][4].replace(']', '').replace(""'"", '') newTable.append(table[i]) trans = [[0 for _ in range(len(newTable))] for _ in range(len(newTable[0]))] for i in range(len(newTable)): for j in range(len(newTable[i])): trans[j][i] = newTable[i][j] trans.remove(trans[3]) return trans" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('/') i[n] = hop[2] return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('Да', 'true') i[n] = i[n].replace('Нет', 'false') return lst def format_procent(lst, n): for i in lst: j = float(i[n][:-1]) / 100 i[n] = '{0:.4f}'.format(j) return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = j[1] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][3:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('@')[0] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = format_data(lst, 0) lst = format_procent(lst, 1) lst = surname_format(lst, 2) lst = telephone_format(lst, 3) return lst" "def main(table): table = dupremove(table) retTable = [] for i in table: retTableBuffer = [] retTableBuffer.append(name(i[0])) retTableBuffer.append(i[3].replace('[at]', '@')) retTableBuffer.append(percentag(i[4])) retTableBuffer.append(trueFalseFormat(i[5])) retTable.append(retTableBuffer) retTable = sorted(retTable, key=lambda x: x[1]) return retTable def percentag(str): num = int(str.replace('%', '')) num = num / 100 return '%.4f' % round(num, 4) def name(str): return str[0] + '. ' + str[5:] def trueFalseFormat(str): if str == 'нет': return 'false' else: return 'true' def dupremove(ls): res = [] for i in ls: if i not in res: res.append(i) return res" "def main(x): for i in range(0, len(x)): x1 = [] for k in range(0, len(x[i])): if x[i][k] is not None: ch = 0 for j in range(0, k): if x[i][k] == x[i][j]: ch = 1 if ch == 0: x1.append(x[i][k]) x[i] = x1 x1 = [] for i in x: if i not in x1: x1.append(i) x = x1 for i in range(0, len(x)): x[i][0] = x[i][0].replace('.', '/') x[i][1] = float(x[i][1]) x[i][1] = round(x[i][1], 2) x[i][1] = x[i][1] * 100 x[i][1] = int(x[i][1]) x[i][1] = str(x[i][1]) x[i][1] = x[i][1] + '%' match x[i][2][0]: case 'д': x[i].append('Y') case 'н': x[i].append('N') x[i][2] = x[i][2][x[i][2].find(']') + 1:len(x[i][2])] return x" "def transform(table): result_table = [] for line in table: line = set(line) column_begin = None column_2 = None column_3 = None column_end = 'нет' for item in line: if item is None: break if '&' in item: split = item.split('&') column_begin = ''.join(split[1].replace('[at]', '@')) column_3 = str(round(float(split[0].replace('%', '')) / 100, 1)) if '.' in item and ' ' in item: (name, abb, surname) = item.split(' ') column_2 = f'{name} {surname}' if 'Выполнено' == item: column_end = 'да' if not column_begin: continue new_line = [column_begin, column_2, column_3, column_end] if new_line not in result_table: result_table.append(new_line) return result_table def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def main(table): return transpose(transform(table))" "def main(tmp_tb): for i in range(len(tmp_tb)): tmp_tb[i].pop(1) Stol = 1 Simv = 14 for i in range(len(tmp_tb)): new_str = tmp_tb[i][Stol][0:Simv] tmp_tb[i][Stol] = tmp_tb[i][Stol][Simv + 1:] tmp_tb[i].insert(Stol, new_str) tmp_tb[i][0] = str(round(float(tmp_tb[i][0]), 1)) f = 4 tmp_tb[i][1] = tmp_tb[i][1][f + 2:len(tmp_tb[i][1])] Name = tmp_tb[i][2][0] pr1 = 0 pr2 = 0 tmp_tb[i][1] = tmp_tb[i][1][:6] + '-' + tmp_tb[i][1][6:] for k in range(len(tmp_tb[i][2])): if tmp_tb[i][2][k] == ' ': pr1 = k pr2 = k + 3 break FatherName = tmp_tb[i][2][pr1 + 1] F = tmp_tb[i][2][pr2 + 1:] tmp_tb[i][2] = F + ', ' + Name + '.' + FatherName + '.' tb2 = [[None for _ in range(len(tmp_tb))] for _ in range(len(tmp_tb[0]))] for y in range(len(tmp_tb)): for x in range(len(tmp_tb[y])): tb2[x][y] = tmp_tb[y][x] return tb2" "def main(t): t = list(map(lambda l: list(filter(lambda x: x is not None, l)), t)) t = list(filter(None, t)) t = list(map(lambda x: ['(' + x[0][0:3] + ') ' + x[0][4:7] + '-' + x[0][8:10] + '-' + x[0][10:12], x[1][6:8] + '/' + x[1][3:5] + '/' + x[1][0:2], '1' if x[2] == 'Y' else '0'], t)) return list(t)" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[0] i.insert(a, s[1]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('/') i[n] = hop[2] return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('Да', 'true') i[n] = i[n].replace('Нет', 'false') return lst def format_procent(lst, n): for i in lst: j = float(i[n][:-1]) / 100 i[n] = '{0:.4f}'.format(j) return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = f'{j[0][:1]}.{j[1]} {j[2]}' return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][9:15] + i[n][16:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('@')[0] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = splt(lst, 0, 2, sep='#') lst = email_format(lst, 1) lst = surname_format(lst, 2) lst = telephone_format(lst, 0) lst.sort(key=lambda x: x[0]) return lst" "def delete_duplicate_column(table): for row in table: del row[2] return table def delete_empty_rows(table): return [row for row in table if row[0] is not None] def add_zerous(table): for i in range(len(table)): table[i][0] += '00' return table def change_date(table): for i in range(len(table)): t = table[i][2][0:2] t2 = table[i][2][2:6] t3 = table[i][2][6:8] table[i][2] = t3 + t2 + t return table def change_number(table): for i in range(len(table)): table[i][3] = table[i][3][5:] for i in range(len(table)): table[i][1] = table[i][1][:-6] return table def main(table): return change_number(change_date(add_zerous(delete_duplicate_column(delete_empty_rows(table)))))" "def check(comp1, comp2): for i in range(0, len(comp2)): if comp1 == comp2[i]: return True return False def bro(mys, chs): for i in range(0, len(chs[0])): mys.append([]) for j in range(0, len(chs)): if i == j: mys[i].append(chs[i][j]) else: mys[i].append(chs[j][i]) def main(s): mys = [] chs = [] for row in s: cont = [] for elem in row: stri = str(elem) stri = stri.replace('true', 'Y') stri = stri.replace('false', 'N') stri = stri.replace('200', '0', 1) stri = stri.replace('199', '9', 1) stri = stri.replace(' (', '') stri = stri.replace(') ', '') stri = stri.replace('/', '!', 2) stri = stri.replace('-', '', 2) stri = stri.replace('!', '-', 2) elem = stri if not check(elem, cont): if elem.find(';') == -1: cont.append(elem) else: elem = elem.split(';') for popa in elem: stri = popa if stri.find('-') == -1: stri = '%.2f' % float(stri) else: cont.append(stri) if not check(cont, chs): chs.append(cont) bro(mys, chs) return mys" "def deleteEmptyRows(table): newTable = [] for row in table: if row[0] is not None: newTable.append(row) return newTable def transpone(table): newTable = [] for i in range(len(table[0])): newTable.append([]) for j in range(len(table)): newTable[i].append(table[j][i]) return newTable def deleteEmptyColumns(table): newTable = table newTable = transpone(newTable) newTable = deleteEmptyRows(newTable) newTable = transpone(newTable) return newTable def deleteSimilarRows(table): newTable = table for i in range(len(newTable[0])): for j in range(i + 1, len(newTable[0])): if newTable[0][i] == newTable[0][j]: for k in range(len(newTable)): newTable[k][j] = None return newTable def transform(table): for i in range(len(table)): s = table[i][2].split('&') s[0] = s[0].split('@')[1] ss = s[1].split('/') s[1] = ss[2] + '-' + ss[1] + '-' + ss[0] table[i][2] = s[1] table[i].append(s[0]) table[i][0] = table[i][0][1:4] + table[i][0][6:9] + table[i][0][10:14] if table[i][1] == 'Не выполнено': table[i][1] = 'false' else: table[i][1] = 'true' return table def main(table): table = deleteEmptyRows(table) table = deleteSimilarRows(table) table = deleteEmptyColumns(table) table = transform(table) table = transpone(table) return table" "def delete_duplicate(table): for i in range(0, len(table)): j = i + 1 while j < len(table): if table[i] == table[j]: del table[j] j += 1 return table def transform(table): for i in range(0, len(table)): table[i][2] = table[i][1][table[i][1].find(':') + 1:] table[i][1] = table[i][1][table[i][1].find('@') + 1:table[i][1].find(':')] b = table[i][2][-4:] + '.' + table[i][2][3:-5] table[i][2] = b + '.' + table[i][2][:2] table[i][0] = table[i][0].split() a = table[i][0][2] + ' ' + table[i][0][0][0] table[i][0] = a + '.' + table[i][0][1] return table def transpose(table): res = [] for i in range(0, len(table[0])): res.append([]) for j in range(0, len(table)): res[i].append(table[j][i]) return res def main(table): table = transform(table) table = delete_duplicate(table) table = transpose(table) return table" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_duplicate_columns(table): for row in table: del row[2] return table def delete_duplicate_rows(table): setBuff = set() newTable = [] for itemBuff in table: t = tuple(itemBuff) if t not in setBuff: newTable.append(itemBuff) setBuff.add(t) return newTable def change_symbols(table): for itemBuff in table: setBuff = itemBuff[0] itemBuff[0] = setBuff.replace('+7', '').replace(')', ') ').replace('[at]', '@') return table def split_column(table): for itemBuff in table: strBuff = itemBuff[0].split('|') itemBuff[0] = strBuff[0] sep = strBuff[1].find('[') itemBuff.insert(0, strBuff[1][0:sep + 100]) return table def name_change(table): for itemBuff in table: strBuff = itemBuff[1] sep = strBuff.find(' ') strName = strBuff[sep + 1:sep + 10] strBuff = strName itemBuff[1] = strBuff return table def round_numbers(table): for itemBuff in table: strBuff = format(float(itemBuff[2]), '.4f') itemBuff[2] = str(strBuff) return table def main(table): table = delete_duplicate_columns(table) table = delete_duplicate_rows(table) table = change_symbols(table) table = name_change(table) table = round_numbers(table) table = split_column(table) table = transpose(table) return table" "def delete_duplicate(table): for row in table: del row[2] return table def stripper(table): for row in table: row[1] = row[1][4:] return table def new_stripper(table): for row in table: row[0] = row[0].replace('@', '[at]') return table def deleter(table): for row in table: row[3] = round(float(row[3]), 2) row[3] = str(row[3]) if len(row[3]) == 3: row[3] = row[3] + '0' return table def ending(table): for row in table: row[2] = row[2].split(' ') row[2][0] = row[2][0][:1] + '.' row[2] = row[2][2] + ' ' + row[2][0] + row[2][1] return table def main(table): return ending(deleter(new_stripper(stripper(delete_duplicate(table)))))" "def doOneList(entr_list): one_list = [] for i in range(len(entr_list)): for j in range(len(entr_list[i])): one_list.append(entr_list[i][j]) return one_list def removeRepeats(entr_values): uniq_values = [] [uniq_values.append(x) for x in entr_values if x not in uniq_values] return uniq_values def addColumn(enter_values): i = 0 while i < len(enter_values): tabul = enter_values[i].find('|') if tabul != -1: tmp1 = enter_values[i][0:tabul] tmp2 = enter_values[i][tabul + 1:len(enter_values[i])] enter_values[i] = tmp2 enter_values.insert(i + 3, tmp1) i += 1 return enter_values def format_2(num): tmp = str(num) if len(tmp) < 4: tmp += '0' return tmp def format(enter_values): for i in range(len(enter_values)): if i % 4 == 0: k = enter_values[i].find('/') - 2 f = len(enter_values[i]) j = enter_values[i][k:f] enter_values[i] = j elif i % 4 == 1: enter_values[i] = enter_values[i][0:enter_values[i].find('@')] elif i % 4 == 2: num = float(enter_values[i][0:len(enter_values[i]) - 1]) num = num / 100 enter_values[i] = format_2(num) elif i % 4 == 3: tmp_str = '' for j in range(len(enter_values[i])): if enter_values[i][j] == '+' or enter_values[i][j] == ' ' or enter_values[i][j] == '-': pass else: tmp_str += enter_values[i][j] enter_values[i] = '+' + tmp_str[0] + ' (' + tmp_str[1:4] + ') ' + tmp_str[4:7] + '-' + tmp_str[7:9] + '-' + tmp_str[9:11] return enter_values def sort(enter_values): sort_list = [] values_to_sort = [] for i in range(len(enter_values)): for j in range(len(enter_values[i])): if j % 4 == 0: values_to_sort.append(enter_values[i][j]) values_to_sort.sort() position = 0 while position < len(values_to_sort): for i in range(len(enter_values)): if position < len(values_to_sort) and enter_values[i][0] == values_to_sort[position]: position += 1 sort_list.append(enter_values[i]) return sort_list def doLists(sorted_list): result = [] tmp = [] for i in range(len(sorted_list)): tmp.append(sorted_list[i]) if i % 4 == 3 and i != 0: result.append(tmp) tmp = [] return result def main(entr_values): values = doOneList(entr_values) i = 0 while i < len(values): if values[i] is None: values.pop(i) else: i += 1 return sort(doLists(format(addColumn(removeRepeats(values)))))" "def main(x): h = [] z = [] for i in range(len(x)): match h.count(x[i]): case 0: h.append(x[i]) case _: h.append([]) z1 = [] for j in range(len(h[i])): if h[i][j] is not None: z1.append(h[i][j]) match len(z1): case 0: continue case _: match z.count(z1): case 0: z.append(z1) case _: continue h[i] = z1 x = z for i in range(len(x)): z = [] for j in range(len(x[i])): match z.count(x[i][j]): case 0: z.append(x[i][j]) x[i] = z for i in range(len(x)): for j in range(len(x[i])): match j: case 0: v = [] v.extend(x[i][j]) v.pop(0) v.pop(0) v.pop(0) v.pop(0) v.pop(0) v.pop(0) v.pop(len(v) - 3) v = ''.join(v) x[i][j] = v case 1: x[i][j] = str(x[i][j]) + '000' case 2: z = x[i][j].split('-') z.reverse() x[i][j] = '.'.join(z) case 3: z = x[i][j].split('@') z.insert(1, '[at]') x[i][j] = ''.join(z) z = [] for i in range(4): some = [] for j in range(len(x)): some.append(x[j][i]) z.append(some) x = z return x" "def delete_duplicate(table): for i in range(0, len(table)): j = i + 1 while j < len(table): if table[i] == table[j]: del table[j] j += 1 return table def transform(table): for i in range(0, len(table)): table[i][0] = table[i][0][-2:] + table[i][0][2:-2] + table[i][0][:2] table[i][2] = table[i][1][:table[i][1].find('&')] table[i][1] = '(' + table[i][1][table[i][1].find('&') + 1:] table[i][1] = table[i][1].replace('-', ') ', 1) a = table[i][2][0] + '.' table[i][2] = a + table[i][2][table[i][2].find(' ') + 1:] table[i][3] = str(round(float(table[i][3]), 2)) if len(table[i][3]) == 3: table[i][3] = table[i][3] + '0' return table def transpose(table): res = [] for i in range(0, len(table[0])): res.append([]) for j in range(0, len(table)): res[i].append(table[j][i]) return res def main(table): table = transform(table) table = delete_duplicate(table) table = transpose(table) return table" "def main(string): result_lst = [] for i in range(len(string)): if string[i] != [None, None, None, None, None]: lst = [] s1 = string[i][0] + '0' lst.append(s1) s2 = string[i][1].replace(' ', '') s2 = s2.replace('+7(', '') s2 = s2.replace(')', '') s2 = s2.replace('-', '') lst.append(s2) s3 = string[i][2].split('.') lst.append(f'{s3[1].strip()} {s3[0][:-2]}') s4 = string[i][3].split('[at]')[1] lst.append(s4) if lst not in result_lst: result_lst.append(lst) return result_lst" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[0] i.insert(a, s[1]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('/') i[n] = f'{hop[0]}-{hop[1]}-{hop[2]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('false', '0') i[n] = i[n].replace('true', '1') return lst def format_procent(lst, n): for i in lst: j = float(i[n][:-1]) / 100 i[n] = '{0:.4f}'.format(j) return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = f'{j[2]} {j[0][:1]}.{j[1]}' return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][9:15] + i[n][16:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('[at]')[1] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = splt(lst, 2, 3, sep='!') lst = format_data(lst, 0) lst = true_format(lst, 1) lst = email_format(lst, 2) lst = surname_format(lst, 3) lst = transpose(lst) return lst" "def remove_empty_cols(table): return [[row[0], row[2], row[4], row[5]] for row in table] def remove_duplicate_rows(table): newTable = [] for i in table: if i not in newTable: newTable.append(i) return newTable def remove_empty_rows(table): return [row for row in table if row[0] is not None] def transformer(i, value): if i == 0: return 'true' if value == '1' else 'false' if i == 1: value = value.replace('+7', '').replace('(', '') value = value.replace(')', '').replace('\n', '').replace('-', '') return value[0:3] + ' ' + value[3:6] + '-' + value[6:] if i == 2: return value.replace('@', '[at]') if i == 3: value = value.replace('\n', ' ').replace(' ', ' ').split(' ') return value[0][0:1] + '.' + value[1] + ' ' + value[2] def transform(table): for j in range(len(table)): for i in range(len(table[j])): table[j][i] = transformer(i, table[j][i]) return table def main(table): return transform(remove_empty_rows(remove_duplicate_rows(remove_empty_cols(table))))" "def f(lul): n = [] for i in lul: if i not in n and i[0] is not None: n.append(i) return n def trans(matrix): trans_matrix = [[0 for j in range(len(matrix))] for i in range(len(matrix[0]))] for i in range(len(matrix)): for j in range(len(matrix[0])): trans_matrix[j][i] = matrix[i][j] return trans_matrix def main(matrix): matrix = f(matrix) trans_matrix = trans(matrix) trans_matrix = f(trans_matrix) matrix = trans(trans_matrix) for i in matrix: i[0] = i[0].replace('/', '-') i[0] = i[0].replace('да', 'true') i[0] = i[0].replace('нет', 'false') i.insert(0, i[0].split('#')[1]) i[1] = i[1].split('#')[0] for j in range(2, len(i)): i[j] = i[j][3:13] + i[j][14:] return trans(matrix)" "def delete_empty_columns(table): for i in range(len(table)): table[i] = [cell for cell in table[i] if cell is not None] return table def transformer(j, value): if j == 0: splitted = value.split(';') first = 'Выполнено' if splitted[0] == 'Y' else 'Не выполнено' splitted_two = splitted[1].split('-') second = '(' + splitted_two[0] + ') ' + '-'.join(splitted_two[1:]) return [first, second] if j == 2: return value.replace('.', '/') def transform(table): for i in range(len(table)): for j in range(len(table[i])): if j == 0: tmp = table[i][1:] table[i] = transformer(j, table[i][j]) table[i] += tmp else: table[i][j + 1] = transformer(j + 1, table[i][j + 1]) return table def main(table): return transform(delete_empty_columns(table))" "def step1(table): j = 0 while j < len(table): if table[j][0] is None: del table[j] else: j += 1 def step2(table): i_len = len(table) for i in range(i_len): j = 0 while j < len(table[i]): if table[i][j] is None: del table[i][j] else: j += 1 def step3(table): temp = [] for x in table: if x not in temp: temp.append(x) return temp def step4(table): for i in range(len(table)): if table[i][0] == 'true': table[i][0] = 'Y' else: table[i][0] = 'N' table[i][1] = table[i][1].replace('/', '-') table[i][2] = table[i][2][:2] + table[i][2][4:] table[i][3] = str(round(float(table[i][3]) * 100 - 0.01)) + '%' def step5(table): trans_table = [[table[j][i] for j in range(len(table))] for i in range(len(table[0]))] return trans_table def main(table): step1(table) step2(table) table = step3(table) step4(table) table = step5(table) return table" "def main(matrix): size = len(matrix) table = [] str = [] for i in range(0, size): name = matrix[i][0].split()[1] str.append(name) percent = int(float(matrix[i][1]) * 100) str.append('{0}{1}'.format(percent, '%')) if matrix[i][3] == 'Y': status = 'да' elif matrix[i][3] == 'N': status = 'нет' str.append(status) mail = matrix[i][4].split('[at]')[0] str.append(mail) table.append(str) str = [] return table" "def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_rows(table): for i in range(len(table)): for j in range(i + 1, len(table)): if set(table[j]) != set(table[i]): table[j] = table[j] else: table[j] = [None] return table def delete_empty_columns(table): for row in table: del row[2] return table def delete_duplicate_columns(table): for row in table: del row[4] return table def transformer(j, value): if j == 0: replaced = value.replace(' ', '').replace('-', '') return replaced[5:] if j == 1: return '0' if value == 'Не выполнено' else '1' if j == 2: return str(round(float(value), 1)) def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def main(table): return transpose(transform(delete_empty_rows(delete_duplicate_rows(delete_empty_columns(delete_duplicate_columns(table))))))" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_columns(table): return [[row[0], row[1], row[4]] for row in table] def transformer(i, value): if i == 0: name = value.split() return f'{name[2]}' if i == 1: return 'Нет' if value == 'Не выполнено' else 'Да' if i == 2: str_year = value[2:4] str_month = value[5:7] str_day = value[8:10] return str_day + '.' + str_month + '.' + str_year def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_empty_columns(table)))" "def main(x): for i in range(len(x) - 1, -1, -1): if x[i] == [None, None, None, None]: x.pop(i) y = [] for i in x: y.append([0, 0, 'Нет']) i.pop(2) i.pop(0) for i in range(len(x)): if x[i][0][1] == '%': y[i][0] = str('0.0' + x[i][0][0]) else: y[i][0] = str('0.' + x[i][0][0] + x[i][0][1]) y[i][1] = x[i][0][-9] + x[i][0][-8] + x[i][0][-7] + x[i][0][-6] + x[i][0][-5] + x[i][0][-4] + x[i][0][-2] + x[i][0][-1] y[i][2] = 'Нет' if x[i][1] == 'Не выполнено' else 'Да' i = 0 while i < len(y): j = i + 1 while j < len(y): if y[i] == y[j]: y.pop(j) j += 1 i += 1 return y" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def transformer(i, value): if i == 0: return value[-7:] if i == 1: split = value.split('@') return split[1] if i == 2: rounded = round(float(value), 2) result = str(int(round(rounded * 100))) + '%' return result def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_empty_rows(table)))" "import re def delStr(mas): for i in range(len(mas)): if mas[i] == [None, None, None]: mas.pop(i) delStr(mas) break def calendar_plus(table): for i in range(len(table)): mas = [] mas = table[i][0].split('#') table[i][0] = mas[0] table[i][2] = mas[1] + '0' return table def replace_yn(table): for i in range(len(table)): table[i][1] = table[i][1].replace('Выполнено', '1') table[i][1] = table[i][1].replace('Не выполнено', '0') def replace_cifri(table): for i in range(len(table)): mascifr = re.findall('(\\d*)\\.(\\d*)\\...(\\d*)', table[i][0]) table[i][0] = mascifr[0][2] + '/' + mascifr[0][1] + '/' + mascifr[0][0] def main(table): delStr(table) calendar_plus(table) replace_cifri(table) replace_yn(table) return table" "def main(s): for i in range(len(s)): s[i] = another(s[i]) strans = [[s[j][i] for j in range(len(s))] for i in range(len(s[0]))] return strans def another(s): s.append(s[0][11:]) s.insert(0, s[0][:10]) del s[1] s[0] = s[0].replace('.', '-') z1 = '(' z2 = s[1][:3] z3 = ') ' z4 = s[1][4:] s[1] = z1 + z2 + z3 + z4 s[2] = s[2].replace('@', '[at]') x = float(s[3]) x = x * 100 x = int(x) x = str(x) x1 = '%' x = x + x1 s[3] = x return s" "def main(input): for i in input: i[0] = i[0].replace(' ', '').replace('-', '') i.insert(1, 'Y') if i[1].split('&')[1] == 'Выполнено' else i.insert(1, 'N') i[2] = f""{int(round(float(i[2].split('&')[0]) * 100))}%"" i[3] = i[3].replace('@', '[at]') input = sorted(input, key=lambda obj: obj[3]) return list(map(list, zip(*input)))" "def transpose(arr): return [[row[i] for row in arr] for i in range(len(arr[0]))] def main(input): for spisok in input: temp = spisok[0].split(' ') spisok[0] = temp[1][:2] + ' ' + temp[0] spisok[1] = spisok[1].replace('@', '[at]', 1) spisok[2] = spisok[2][7:11] + spisok[2][11:].replace('-', '', 1) input = sorted(input, key=lambda d: d[0]) input = transpose(input) return input" "def custom_key(res): return res[3] def main(string): result_lst = [] for i in range(len(string)): if string[i] != [None, None, None, None, None]: lst = [] s1 = string[i][0] if s1 == '0': s1 = 'нет' else: s1 = 'да' lst.append(s1) s2 = string[i][1] + '0' lst.append(s2) el1 = string[i][4].split('/')[2] el2 = string[i][4].split('/')[1] el3 = string[i][4].split('/')[0] lst.append(f'{el1}-{el2}-{el3}') lst.append(string[i][5].split()[0]) if lst not in result_lst: result_lst.append(lst) result_lst.sort(key=custom_key) return result_lst" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): for row in table: del row[2] del row[1] return table def transformer(i, value): if i == 0: replaced = value.replace('+7', '') return replaced[1:] if i == 1: DomainID = value.find('@') domain = value[DomainID + 1:] return domain if i == 2: DotID = value.find('.') newName = value[DotID - 1:DotID + 1] + ' ' + value[0:DotID - 2] return newName if i == 3: newNum = float(value) return f'{round(newNum, 1)}' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_empty_rows(table)))" "def delete_duplicate_columns(table): for row in table: del row[2] return table def transformer(i, value): if i == 0: replaced = value.replace('@', '[at]') return replaced if i == 1: return 'Выполнено' if value == 'да' else 'Не выполнено' if i == 2: digit_str = value.replace('%', '') digit = float(digit_str) / 100 return f'{digit:.2f}00' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(delete_duplicate_columns(table))" "def del_row(s): s1 = [] for row in s: if row not in s1: s1.append(row) return s1 def transpose(s): s1 = [] for i in range(len(s[0])): s1.append([]) for j in range(len(s)): s1[i].append(s[j][i]) return s1 def main(s): s = [row for row in s if row[0] is not None] s = del_row(s) for row in s: buff = row[0].split('&') row[0] = buff[1].split(' ')[1] row.insert(2, '.'.join(reversed(buff[0].split('.')))) b = row[1].split(' ')[2].split('-') row[1] = b[0] + '-' + b[1] + b[2] row[3] = '1' if row[3] == 'Да' else '0' s.sort(key=lambda x: x[0], reverse=False) s = transpose(s) return s" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_cols(table): for row in table: del row[3] return table def delete_duplicate_columns(table): for row in table: del row[3] return table def comp(table, a, b): for i in range(len(table[a])): if table[a][i] != table[b][i]: return 0 return 1 def delete_duplicate_rows(table): i = 0 while i < len(table): j = i + 1 while j < len(table): check = comp(table, i, j) if check == 1: del table[j] continue j += 1 i += 1 return table def transformer(j, value): if j == 0: name = value.split('.') name2 = name[0] + '.' return name2 if j == 1: return '1' if value == 'Выполнено' else '0' if j == 2: num = float(value) num2 = round(num, 2) num3 = int(num * 100) s = str(num3) return s + '%' if j == 3: a = value.split('/') y = a[2] ynew = y[2:] s = ynew + '-' + a[1] + '-' + a[0] return s def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): st1 = delete_duplicate_columns(table) st2 = delete_empty_cols(st1) st3 = delete_duplicate_rows(st2) st4 = transform(st3) st5 = transpose(st4) return st5" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('/') i[n] = f'{hop[0]}-{hop[1]}-{hop[2]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('да', 'Y') i[n] = i[n].replace('нет', 'N') return lst def format_procent(lst, n): for i in lst: i[n] = '{0:.3f}'.format(float(i[n])) return lst def surname_format(lst, n): for i in lst: j = i[n].split(',') i[n] = f'{j[0]}{j[1][:3]}' return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][9:15] + i[n][16:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('@')[0] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = splt(lst, 0, 1, sep=':') lst = true_format(lst, 0) lst = email_format(lst, 2) lst = format_procent(lst, 1) lst = surname_format(lst, 3) lst = transpose(lst) return lst" "def changes1(st3): st3[0] = st3[0].replace('.', '/') st3[0] = st3[0][:14] + '-' + st3[0][14:] st3.append(st3[0][8:10] + st3[0][4:8] + st3[0][0:4]) st3[0] = st3[0][11:] st3[1] = st3[1][0:2] + st3[1][4:] return st3 def delete_empty_rows(table): return [row for row in table if row[0] is not None] def main(st_0): for i in range(len(st_0)): st_0[i] = list(filter(None, st_0[i])) st_0 = list(filter(None, st_0)) for i in st_0: del i[2] new_list = [] for i in st_0: if i not in new_list: new_list.append(i) for i in range(len(new_list)): changes1(new_list[i]) return new_list" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('-') i[n] = f'{hop[2]}.{hop[1]}.{hop[0]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('да', 'Y') i[n] = i[n].replace('нет', 'N') return lst def format_procent(lst, n): for i in lst: i[n] = '{0:.3f}'.format(float(i[n])) return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = j[2] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][9:15] + i[n][16:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('@')[1] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = splt(lst, 0, 1, sep=':') lst = format_data(lst, 1) lst = email_format(lst, 2) lst = surname_format(lst, 0) lst = transpose(lst) return lst" "def main(_list): while [None, None, None] in _list: _list.remove([None, None, None]) for i in _list: i[0] = i[0][i[0].find('.') + 1:] i[0] = i[0].strip() temp = i[2].split(';') i[1] = temp[1] i[1] = i[1].replace('-', ' ', 1) i[2] = temp[0] i[2] = i[2][i[2].find('@') + 1:] (i[0], i[1]) = (i[1], i[0]) _list.sort() for i in _list: while _list.count(i) > 1: _list.remove(i) for i in _list: (i[0], i[1]) = (i[1], i[0]) _list = list(map(list, zip(*_list))) return _list" "import re import math def delete_duplicate_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): for row in table: del row[0] return table def transformer(i, value): if i == 0: name = value.split() return f'{name[1]} {name[0]}' if i == 1: phone = re.findall('\\d{2,3}', value) return f'{phone[0]}{phone[1]}{phone[2]}{phone[3]}' if i == 2: date = value.split('.') return f'{date[0]}' if i == 3: return 'true' if value == 'Y' else 'false' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(delete_duplicate_rows(delete_duplicate_columns(table)))" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] row1 = [] row2 = [] row3 = [] row4 = [] for i in data: i.pop(2) if len(i[0]) == 3: i[0] = '0.' + i[0][:-1] + '0' elif len(i[0]) == 2: i[0] = '0.0' + i[0][:-1] + '0' else: i[0] = '1.000' i[1] = i[1].replace('Да', 'Y') i[1] = i[1].replace('Нет', 'N') i[2] = i[2].replace('(', '').replace(')', '') i[2] = i[2][:10] + i[2][11:] date = datetime.strptime(i[3], '%d-%m-%Y') i[3] = datetime.strftime(date, '%d.%m.%Y') row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) row4.append(i[3]) new_table.append(row1) new_table.append(row2) new_table.append(row3) new_table.append(row4) return new_table" "def main(table): table = elem_none(del_none(del_pov(table))) for i in range(len(table)): if table[i][0][0] == 'Н': table[i][0] = table[i][0].replace('Н', 'н') else: table[i][0] = table[i][0].replace('Д', 'д') table[i][1] = table[i][1].replace('@', '[at]') table[i][3] = table[i][3].split(' ') table[i][3] = table[i][3][0] table[i][2] = table[i][2][4:] return table def elem_none(table): for i in range(len(table)): while table[i].count(None): table[i].remove(None) return table def del_none(table): for elem in table: if elem == [None, None, None, None, None]: table.remove(elem) return table def del_pov(table): table.reverse() for i in table: while table.count(i) != 1: table.remove(i) table.reverse() return table" "def main(x): x1 = [] for i in x: if i != [None, None, None, None]: x1.append(i) x = x1 for i in range(0, len(x)): x1 = [] for j in range(0, len(x[i])): if x[i][j] not in x1: x1.append(x[i][j]) x[i] = x1 x[i][0] = preb1(x[i][0]) if x[i][1] == '0': x[i][1] = 'Не выполнено' else: x[i][1] = 'Выполнено' x[i][2] = x[i][2][x[i][2].find(' ') + 1:] x.sort(key=custom_key) return preb2(x) def preb1(x): if x == '100%': return '1.00' elif len(x) == 2: return '0.0' + x[0] else: return '0.' + x[0:-1] def preb2(x): (x1, x2, x3) = ([], [], []) for i in range(0, len(x)): x1.append(x[i][0]) x2.append(x[i][1]) x3.append(x[i][2]) return [x1, x2, x3] def custom_key(x): return x[2]" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('.') i[n] = f'{hop[0]}-{hop[1]}-{hop[2]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('да', 'Y') i[n] = i[n].replace('нет', 'N') return lst def format_procent(lst, n): for i in lst: i[n] = round(float(i[n]), 2) * 100 i[n] = str(int(i[n])) + '%' return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = f'{j[0]} {j[1][:2]}' return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][9:15] + i[n][16:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('[at]')[1] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = format_data(lst, 1) lst = email_format(lst, 2) lst = format_procent(lst, 0) lst = surname_format(lst, 3) return lst" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): b = [[i for i in item if i is not None] for item in table] c = [item for item in b if item is not None] j = 0 lenlist = len(c) while j < lenlist: if c[j] == []: c.pop(j) lenlist -= 1 else: j += 1 return c def delete_duplicate_columns(table): for row in table: del row[2] return table def transformer(i, value): if i == 0: digit_str = value.replace('%', '') digit = float(digit_str) / 100 return f'{digit:.3f}' if i == 2: return 'Выполнено' if value == 'true' else 'Не выполнено' def transformS(table): for i in range(len(table)): for j in range(len(table[i])): if i == 0: table[i][j] = transformer(i, table[i][j]) if i == 2: table[i][j] = transformer(i, table[i][j]) return table def splitter(table): fio = [] razmer = len(table[1]) for i in range(razmer): name = table[1][i].split(':') a = name[0] a = a.split('.') fio.append(a[0] + '.' + a[2]) b = name[1] b = b.split(' ') table[1][i] = b[2] table.append(fio) return table def main(table): a = delete_empty_rows(transpose(table)) table = splitter(a) table = transformS(table) return table" "def main(table): table = del_pov(table) for i in range(len(table)): table[i][0] = table[i][0].split(',') table[i][0] = table[i][0][0] table[i][1] = table[i][1].replace('@', '[at]') table[i][2] = str(round(float(table[i][2]), 1)) return sorted(table) def del_pov(table): for i in table: i.reverse() for elem in i: while i.count(elem) != 1: i.remove(elem) i.reverse() return table" "def main(x): table = [] for i in x: if i not in table and i != [None, None, None, None]: table.append(i) for index in range(0, len(table)): row1 = [] row = table[index] tmp2 = row[0].split(';') tmp = tmp2[0].split('-') table[index][2] = tmp[0][2] + tmp[0][3] + '.' + tmp[1] + '.' + tmp[2] tmp3 = tmp2[1].replace(' ', '').replace('-', '') table[index][0] = tmp3 chislo = int(row[1].replace('%', '')) table[index][1] = str(round(chislo / 100, 1)) ttmp = row[3].replace(' ', '').split('.') table[index][3] = ttmp[2] + ' ' + ttmp[0] + '.' table.sort(key=lambda i: i[0]) return table" "import re def main(old_table): empty_row = [None for col in range(len(old_table[0]))] new_table = [] for i in old_table: j = i[2] i[0] = re.split('/', i[0])[0] i[2] = re.split(':', i[1])[-1] + '0' a = re.split(' ', i[1])[1].strip('()') b = re.split(' ', re.split(':', i[1])[0])[-1] b = re.split('-', b) b = b[0] + '-' + b[1] + b[2] i[1] = a + ' ' + b a = re.split(' ', j) b = a[-1] + ', ' + a[0][0] + '.' + a[1] j = b i.append(j) new_table.append(i) row_len = len(new_table[0]) col_len = len(new_table) return [[new_table[j][i] for j in range(col_len)] for i in range(row_len)]" "def main(nbook): n2 = [] for i in nbook: if i not in n2 and i[0] is not None: n2.append(i) for i in range(0, len(n2)): stroka = n2[i][0] stroka = stroka.split(';') stroka1 = stroka[1].split('/') stroka1n = stroka1[-1] + '.' + stroka1[-2] + '.' stroka1n += stroka1[-3][-2] + stroka1[-3][-1] n2[i][0] = stroka1 stroka = stroka[0].split(' ') stroka3 = stroka[1][0] + stroka[1][1] + ' ' + stroka[0] stroka4 = n2[i][3].split('-') stroka4 = stroka4[0] + '-' + stroka4[1] + stroka4[2] n2[i][3] = n2[i][2] + '0' n2[i] = [stroka1n, n2[i][3], stroka3, stroka4] return n2" "def main(table): new_table = [[], [], []] for row in table: while row[0] is None: del row[0] for row in table: splited = row[0].split(':') new_table[0].append(''.join(splited[0]).split('.').pop(not -1) + '.') new_table[1].append(splited[1].replace('[at]', '@')) new_table[2].append('.'.join(row[1].split('/'))) return new_table" "def main(matrix): table = [] str = [] size = len(matrix) for i in range(0, size): try: date = matrix[i][0].split('-') year = date[2] month = date[1] day = date[0] date = '{0}/{1}/{2}'.format(year, month, day) str.append(date) except Exception as ex: date = None try: mail = matrix[i][1].replace('[at]', '@') str.append(mail) except Exception as ex: mail = None try: value = '{:.{}f}'.format(int(matrix[i][3].replace('%', '')) / 100, 3) str.append(value) except Exception as ex: value = None if matrix[i][5] is not None: status = matrix[i][5] if status == 'да': status = 'Да' if status == 'нет': status = 'Нет' str.append(status) if len(str) > 0: if str not in table: table.append(str) str = [] return table" "def main(a): table = [] for i in range(len(a)): new = ['', '', '', ''] j = 3 while j != len(a[i][0]): if a[i][0][j] != ' ' and a[i][0][j] != '-': new[0] = new[0] + a[i][0][j] j = j + 1 b = False for j in table: if new[0] == j[0]: b = True break if b: continue if a[i][1] == 'Y': new[1] = 'да' else: new[1] = 'нет' new[2] = a[i][3][6:8] + '/' + a[i][3][3:5] + '/' + a[i][3][0:2] j = 0 while a[i][4][j] != '[': j = j + 1 new[3] = a[i][4][0:j] table.append(new) return table" "def f(lst): n = [] for i in lst: if i not in n: n.append(i) return n def func(string): string = string.split(' ') string = str(string[1][0] + '. ' + string[0]) return string def main(data: list): data = f(data) for i in range(len(data)): data[i][0] = data[i][0].replace(',', '') data[i][0] = list(data[i][0]) data[i][0].pop() data[i][0].pop() data[i][0] = ''.join(data[i][0]) data[i][1] = data[i][1].split('-') (data[i][1][0], data[i][1][2]) = (data[i][1][2], data[i][1][0]) data[i][1] = '/'.join(data[i][1]) data[i][2] = str(round(float(data[i][2]), 1)) data[i][3] = data[i][3].replace('@', '[at]') return data" "def main(nbook): n2 = [] for i in nbook: if i not in n2 and i[0] is not None: n2.append(i) for i in range(0, len(n2)): stroka = n2[i][0] stroka = stroka.split(' ') stroka1 = stroka[0][0] + '.' stroka1 += stroka[1] + ' ' + stroka[2] stroka = n2[i][1].split(';') stroka2 = stroka[0].replace('-', ' ', 1) stroka = stroka[1].split('/') stroka4 = stroka[-1] + '-' + stroka[-2] stroka4 += '-' + stroka[-3] stroka3 = n2[i][2] stroka3 = str(round(float(stroka3), 2)) if len(stroka3) == 3: stroka3 += '0' n2[i] = [stroka1, stroka2, stroka3, stroka4] for j in range(len(n2) - 1): for i in range(len(n2) - 1): if n2[i][0] > n2[i + 1][0]: (n2[i], n2[i + 1]) = (n2[i + 1], n2[i]) return n2" "def changes1(st3): st3.insert(1, st3[0].split(';')[1]) st3[0] = st3[0].split(';')[0] st3[2] = st3[2][3:6] + '-' + st3[2][6:10] st3[3] = st3[3].replace('.', '/') if st3[1] == 'нет': st3[1] = 'false' else: st3[1] = 'true' st4 = st3[0].split(' ') st3[0] = st4[1] + ' ' + st4[0] return st3 def main(st_0): for i in range(len(st_0)): st_0[i] = list(filter(None, st_0[i])) st_0 = list(filter(None, st_0)) new_list = [] for i in st_0: if i not in new_list: new_list.append(i) for i in range(len(new_list)): changes1(new_list[i]) return new_list" "def delete_empty_columns(table): for i in range(len(table)): table[i] = [cell for cell in table[i] if cell is not None] return table def delete_duplicate_rows(table): unique_list = [] for row in table: if row not in unique_list: unique_list.append(row) return unique_list def transformer(j, value): if j == 1: splitted = value.split(';') first = splitted[1][:2] + splitted[1][4:] second = splitted[0][2:] return [first, second] if j == 0: tmp = str(round(float(value), 2)) if len(tmp) == 3: tmp = tmp + '0' return str(int(tmp[2:])) + '%' def transform(table): for i in range(len(table)): for j in range(len(table[i])): if j == 1: tmp = table[i][0] table[i] = transformer(j, table[i][j]) table[i] = [tmp] + table[i] else: table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(delete_duplicate_rows(delete_empty_columns(table)))" "def main(table): a = [] for i in range(len(table[0])): for j in range(i + 1, len(table[0])): if False not in [table[k][j] == table[k][i] for k in range(len(table))]: for i in range(len(table)): del table[i][j] j -= 1 for i in table: if i not in a: a.append(i) table = a table = list(map(list, zip(*table))) for i in range(len(table[0])): table[0][i] = table[0][i].split(' ')[1].replace('-', '') table[1][i] = str(int(round(round(float(table[1][i]), 2) * 100))) + '%' table[2][i] = table[2][i].replace('/', '-') return table" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[0] i.insert(a, s[1]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('.') i[n] = f'{hop[0]}-{hop[1]}-{hop[2]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('да', 'Y') i[n] = i[n].replace('нет', 'N') return lst def format_procent(lst, n): for i in lst: j = float(i[n][:-1]) / 100 j = round(j, 1) i[n] = '{0:.1f}'.format(j) return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = j[1] + ' ' + j[0] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][9:15] + i[n][16:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('[at]')[0] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = splt(lst, 0, 1, sep='&') lst = email_format(lst, 2) lst = format_procent(lst, 1) lst = surname_format(lst, 0) return lst" "def first(s): new = [] for i in s: cur = [] for j in i: if j not in cur: cur.append(j) new.append(cur) return new def second(s): new = [] for i in s: cur = [] for j in i: if j is not None: cur.append(j) new.append(cur) return new def third(s): new = [] for i in s: cur = [] cur.append(i[0]) cur.append(i[1].split('|')[0]) cur.append(i[1].split('|')[1]) new.append(cur) return new def fourth(s): for i in s: i[0] = i[0].split('-')[0] + ' ' + i[0][4:] if i[2] == 'Нет': i[2] = 'нет' elif i[2] == 'Да': i[2] = 'да' i[1] = i[1].split(',')[0] return s def fifth(s): new = [] numb = [] y_n = [] sec_name = [] for i in s: numb.append(i[0]) y_n.append(i[2]) sec_name.append(i[1]) new.append(numb) new.append(y_n) new.append(sec_name) return new def main(s): return fifth(fourth(third(second(first(s)))))" "import re def main(my_table): output_table = [] for row in my_table: old_1 = re.findall('\\+7(\\([0-9]{3}\\))([0-9-]{9})', row[0]) old_2 = re.findall('[a-zA-Z0-9]+@([a-z]+\\.[a-z]+)', row[1]) old_4 = re.findall('([0-9]{2})/([0-9]{2})/([0-9]{4})', row[3]) new_first = old_1[0][0] + ' ' + old_1[0][1] new_second = old_2[0] new_third = old_4[0][0] + '-' + old_4[0][1] + '-' + old_4[0][2] my_list = [new_first, new_second, new_third] output_table.append(my_list) return output_table" "def main(X): new_table = [] for x in X: data = list(filter(None, x)) if len(data) > 0: name = data[0].split(' ')[0] mail = '[at]'.join([x for x in data[1].split('@')]) dateofbirth = data[2].replace('-', '/') phone = data[3].split(') ')[1].replace('-', '') new_row = [name, mail, dateofbirth, phone] new_table.append(new_row) ans = [] for i in range(len(new_table[0])): row = [x[i] for x in new_table] ans.append(row) return ans" "def main(table): for i in range(len(table)): table[i][0] = str(int(round(float(table[i][0]) * 100))) + '%' table[i][1] = table[i][1].split('.') table[i][1].reverse() table[i][1] = '/'.join(table[i][1]).replace(' ', '') if table[i][2] == 'false': table[i][2] = '0' else: table[i][2] = '1' table[i][3] = table[i][3].replace('@', '[at]') return table" "def main(table): result = [] dict = [] for row in table: if row in dict: continue dict.append(row) tempRow = [] firstColumn = row[0][0:16] tempRow.append(firstColumn) tempRow[0] = tempRow[0].replace(' ', '(', 1) tempRow[0] = tempRow[0].replace(' ', ')', 1) a = row[2][row[2].find('.') + 2:] + ', ' + row[2][:1] b = '.' + row[2][row[2].find('.') - 1:row[2].find('.') + 1] tempRow.append(a + b) if row[0][17:] == 'Да': tempRow.append('да') else: tempRow.append('нет') tempRow.append(row[4].replace('[at]', '@')) result.append(tempRow) return transpose(result) def transpose(mat): matrix = [] for i in range(len(mat[0])): matrix.append(list()) for j in range(len(mat)): matrix[i].append(mat[j][i]) return matrix" "def main(table): result = [[], [], []] for (_, name, number, _) in table: if not name and (not number): continue (logic, name) = name.split('#') (_, name) = name.split() number = number[0:2] + number[4:7] + number[9:12] + number[13:15] + number[16:18] if number not in result[1]: if logic == '0': result[0].append('N') else: result[0].append('Y') result[1].append(number) result[2].append(name) return result" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('/') i[n] = f'{hop[2]}/{hop[1]}/{hop[0]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('Да', '1') i[n] = i[n].replace('Нет', '0') return lst def format_procent(lst, n): for i in lst: j = float(i[n][:-1]) / 100 j = round(j, 1) i[n] = '{0:.1f}'.format(j) return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = j[0] + ' ' + j[2] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][3:13] + i[n][14:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('@')[0] return lst def main(lst): lst = format_data(lst, 0) lst = true_format(lst, 1) lst = email_format(lst, 2) lst = surname_format(lst, 3) lst.sort(key=lambda x: x[3]) return lst" "import re def main(x): strings = [] for i in range(len(x)): string = [] string.append('(' + x[i][0][:3] + ') ' + x[i][0][4:10] + '-' + x[i][0][10:12]) string.append(x[i][1].replace('@', '[at]')) string.append(x[i][3] + '00') strings.append(string) return strings" "import collections import re class table(object): def __init__(self, x): self.x = x def remove_double_none(self): for i in range(len(self.x)): n = [] for j in self.x[i]: if j not in n: n.append(j) self.x[i] = n self.x[i] = [s for s in self.x[i] if s is not None] return None def remove_empty_rows(self): temp = [] for s in self.x: if len(s) > 0: temp.append(s) self.x = temp def metamorphosis(self): for i in range(len(self.x)): self.x[i][0] = '/'.join([self.x[i][0].split('.')][0][::-1]) self.x[i][1] = self.x[i][1].replace('true', '1').replace('false', '0') self.x[i][2] = self.x[i][2][:3] + ') ' + self.x[i][2][4:] self.x[i][2] = '(' + self.x[i][2] return None def main(x): b = table(x) b.remove_double_none() b.remove_empty_rows() b.metamorphosis() return b.x" "import re def main(nbook): n2 = [] for i in nbook: if i not in n2 and i[1] is not None: n2.append(i) n3 = [] for i in range(0, len(n2)): stroka1 = n2[i][1].split(' ') stroka1 = stroka1[0] stroka = n2[i][2].split('|') stroka3 = stroka[1] stroka = stroka[0] stroka = stroka.split('-') stroka2 = stroka[-1] + '.' + stroka[-2] + '.' + stroka[-3] if stroka3 == 'Нет': stroka3 = 'N' else: stroka3 = 'Y' stroka4 = n2[i][4] stroka4 = stroka4.replace('@', '[at]') n3.append([stroka1, stroka2, stroka3, stroka4]) nbook = [] for i in range(0, len(n3[0])): stroka = [] for j in range(len(n3)): stroka.append(n3[j][i]) nbook.append(stroka) return nbook" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('-') i[n] = f'{hop[2]}/{hop[1]}/{hop[0]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('1', 'Выполнено') i[n] = i[n].replace('0', 'Не выполнено') return lst def format_procent(lst, n): for i in lst: j = float(i[n][:-1]) / 100 j = round(j, 1) i[n] = '{0:.1f}'.format(j) return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = j[1] + ' ' + j[0] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][3:13] + i[n][14:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('[at]')[0] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = splt(lst, 0, 3, sep=':') lst = format_data(lst, 0) lst = true_format(lst, 2) lst = telephone_format(lst, 1) lst = transpose(lst) return lst" "def delete_empty_columns(table): for i in range(len(table[0])): isNone = True for j in range(len(table)): if table[j][i] is not None: isNone = False if isNone: table[0][i] = 'del' for i in range(len(table[0]) - 1, -1, -1): if table[0][i] == 'del': for j in range(len(table)): table[j].remove(table[j][i]) return table def delete_duplicate_rows(table): res = [] for i in table: if i not in res: res.append(i) return res def transformer(i, value): if i == 0: name = value.split(';')[0] return name[2:] if i == 1: name = value[3:] return name[:10] + name[11:] if i == 2: if value.split(';')[1] == 'Y': return 'Да' else: return 'Нет' def transform(table): for i in range(len(table)): table[i].append(transformer(2, table[i][0])) for i in range(len(table)): for j in range(len(table[i]) - 1): table[i][j] = transformer(j, table[i][j]) return table def sorter(table): dict = {} for i in range(len(table)): value = table[i][1].replace(' ', '').replace('-', '') dict[value] = i lst = [] for i in sorted(dict.items()): lst.append(i[1]) return lst def sort(table): order = sorter(table) tab = [] for i in order: tab.append(table[i]) return tab def main(table): return sort(transform(delete_duplicate_rows(delete_empty_columns(table))))" "def main(table): parsed = set() (res_p, score_p, fullname, domain) = ([], [], [], []) for (res, score, _, data) in table: if data in parsed or data is None: continue parsed.add(data) data_s = data.split(':') res_p.append('1' if res == 'true' else '0') score_p.append(f'{round(float(score), 1)}') fullname.append(data_s[1][:-2]) domain.append(data_s[0].split('[at]')[1]) return [res_p, score_p, fullname, domain]" "def main(nbook): n2 = [] for i in nbook: if i not in n2 and i[1] is not None: n2.append(i) n3 = [] for i in range(0, len(n2)): stroka1 = n2[i][0] stroka1 = stroka1.replace('-', '') stroka2 = n2[i][1].split(' ') stroka2[0] = stroka2[0].replace(',', '') stroka2[0] = stroka2[0].replace(' ', '') stroka2[1] = stroka2[1].split('.') stroka = stroka2[1][0] + '. ' stroka += stroka2[0] stroka2 = stroka stroka3 = n2[i][2].replace('%', '') stroka3 = str(round(float(stroka3) / 100, 2)) + '00' if len(stroka3) == 5: stroka3 += '0' if n2[i][4] == 'false': stroka4 = 'нет' else: stroka4 = 'да' n3.append([stroka1, stroka2, stroka3, stroka4]) nbook = [] for i in range(0, len(n3[0])): stroka = [] for j in range(len(n3)): stroka.append(n3[j][i]) nbook.append(stroka) return nbook" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) response.append([]) for i in range(len(response[0])): response[2].append(response[0][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def transformer(i, value): if i == 0: a = value.split('!') return '{:.3f}'.format(float(a[1])) if i == 1: return 'Нет' if value == 'false' else 'Да' if i == 2: a = value.split('!') return a[0].split(' ')[1] def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def dupcheck(table): a = [] table1 = table for i in range(len(table[0]) - 1): for z in range(i + 1, len(table[0])): if table[2][i] == table[2][z]: a.append(z) a = list(set(a)) for i in range(len(a) - 1, -1, -1): for j in table1: del j[a[i]] return table1 def main(table): return dupcheck(transform(transpose(delete_empty_rows(table))))" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def transformer(transformation_type, value): if transformation_type == 0: return '%s %s-%s' % (value[2:5], value[5:8], value[8:]) if transformation_type == 1: return value.split('@')[0] if transformation_type == 2: data = value.split()[1].split(';') data[1] = data[1].casefold() return data def flatten(list_of_lists): flat_list = [] for sub_list in list_of_lists: if type(sub_list) is str: flat_list.append(sub_list) else: flat_list += sub_list return flat_list def transform(table): for row_index in range(len(table)): for item_in_row_index in range(len(table[row_index])): table[row_index][item_in_row_index] = transformer(item_in_row_index, table[row_index][item_in_row_index]) table[row_index] = flatten(table[row_index]) return table def main(data): return transpose(sorted(transform(data)))" "def main(table): table = list(map(list, {tuple(x) for x in table})) for i in range(len(table)): table[i][0] = table[i][0].replace('-', '') for i in range(len(table)): table[i][1] = str(round(float(table[i][1]) * 100)) + '%' for i in range(len(table)): table[i][2] = table[i][2].partition('[')[0] table = sorted(table, key=lambda num: num[0]) table = [[table[j][i] for j in range(len(table))] for i in range(len(table[0]))] return table" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('-') i[n] = f'{hop[2]}/{hop[1]}/{hop[0]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('Y', '1') i[n] = i[n].replace('N', '0') return lst def format_procent(lst, n): for i in lst: j = float(i[n][:-1]) / 100 i[n] = '{0:.2f}'.format(j) return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = j[1] + ' ' + j[0] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][:12] + i[n][13:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('[at]')[0] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = true_format(lst, 2) lst = email_format(lst, 3) lst = format_procent(lst, 0) lst = telephone_format(lst, 1) lst.sort(key=lambda x: x[1]) return lst" "import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] row1 = [] row2 = [] row3 = [] row4 = [] for i in data: i.pop(4) split = i[0].split(' ') i[0] = split[0] i[1] = re.sub('@.*', '', i[1]) i[2] = str(round(float(i[2]), 3)) if len(i[2]) == 4: i[2] += '0' i[3] = i[3][:6] + '-' + i[3][6:] row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) row4.append(i[3]) new_table.append(row1) new_table.append(row2) new_table.append(row3) new_table.append(row4) return new_table" "from operator import itemgetter def main(table): new_table = list() for row in table: if row not in new_table: new_table.append(row) table = new_table for i in range(0, len(table)): if table[i][0] is None: del table[i] break for row in table: if row[0] == 'Нет': row[0] = 'N' else: row[0] = 'Y' row[1] = row[1].split('@')[0] row[2] = row[2][2:] row[3] = row[3].split(' ')[1] table = sorted(table, key=itemgetter(2)) return table" "import re def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def transformer(i, value): if i == 0: name = value.split() return f""{name[2]} {name[0][0] + '.'}{name[1]}"" if i == 1: value = float(value) return f'{value:.4f}' if i == 2: replaced = re.findall('@([a-z0-9_]*\\.[a-z0-9_]*)', value) return replaced[0] if i == 3: replaced1 = value.replace(' ', '').replace('-', '') replaced1 = re.findall('\\)([0-9_]*)', replaced1) return replaced1[0] def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return sorted(transpose(transform(delete_empty_rows(transpose(table)))), key=lambda x: x[3])" "import datetime from datetime import datetime from itertools import chain def transpose(table): response = [] response = [[row[i] for row in table] for i in range(len(table[0]))] (response[2], response[1]) = (response[1], response[2]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): for row in table: del row[2] return table def delete_duplicate_rows(table): temp = [] for row in table: if row not in temp: temp.append(row) table = temp return table def transformer(i, value): if i == 0: x = value.find('.') y = value[x + 2:].split(';') y[1] += '00' return y if i == 1: date_string = value[0:] date_string = datetime.strptime(date_string, '%d-%m-%Y').date() date_object = date_string.strftime('%Y.%m.%d') x = [] x.append(date_object) return x def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) table[i] = list(chain.from_iterable(table[i])) table.sort(key=lambda x: x[0]) return table def main(table): return transpose(transform(delete_duplicate_rows(delete_duplicate_columns(delete_empty_rows(table)))))" "def main(x): x1 = [] for i in x: if i not in x1 and i != [None, None, None]: x1.append(i) x = x1 for i in range(0, len(x)): x[i].insert(0, x[i][0][x[i][0].find('|') + 1:].replace('/', '.')) x[i][1] = preb(x[i][1]) if x[i][2] == 'Y': x[i][2] = 'true' else: x[i][2] = 'false' x[i][3] = x[i][3].replace('-', '') x.sort(key=custom_key) return x def preb(x): x = x[:x.find('|')].split(' ') return x[2] + ' ' + x[0][0] + '.' + x[1] def custom_key(x): return x[3]" "import re def main(nbook): n2 = [] for i in nbook: if i not in n2 and i[0] is not None: n2.append(i) n3 = [] for i in range(0, len(n2)): if n2[i][0] == 'Выполнено': n2[i][0] = 'Y' else: n2[i][0] = 'N' stroka = n2[i][1] stroka = stroka.split('[at]') name = stroka[0] stroka = n2[i][2] stroka = stroka.replace('%', '') if len(stroka) == 1: stroka = '0' + stroka n2[i][2] = '0.' + stroka + '00' elif len(stroka) == 3: n2[i][2] = '1.0000' else: n2[i][2] = '0.' + stroka + '00' n3.append([n2[i][0], name, n2[i][2]]) return n3" "def main2(matrix): mass = list() for i in matrix: if i not in mass and i is not None: mass.append(i) if len(mass) != 0: kek = str(mass[0]).split('.') kek[0] = kek[0][:-2] kek[1] = kek[1][1:] mass[0] = kek[1] + ' ' + kek[0] mass[1] = str(round(float(mass[1]), 1)) mass[2] = mass[2].replace('+7', '').replace('-', '').replace(' ', '') mass[3] = mass[3].replace('Да', 'true').replace('Нет', 'false') return mass def main(matrix): mass = list() for i in matrix: if i not in mass and i[0] is not None and (i[2] is not None) and (i[3] is not None): mass.append(main2(i)) return mass" "import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[1] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] row1 = [] row2 = [] row3 = [] row4 = [] for i in data: i.pop(-1) i.pop(2) i.pop(0) split = i[0].split('|') if split[0] == '1.0': i[0] = '100%' elif split[0] == '0.0': i[0] = '0%' else: i[0] = split[0].replace('0.', '') + '0%' split2 = i[1].split(' ') i[1] = split2[1] if i[2] == 'Нет': i[2] = 'Не выполнено' else: i[2] = 'Выполнено' i.append(re.sub('\\[at\\].*', '', split[1])) row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) row4.append(i[3]) new_table.append(row1) new_table.append(row2) new_table.append(row3) new_table.append(row4) return new_table" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_columns(table): for row in table: del row[2] return table def transformer(i, value): if i == 0: replaced = value return replaced[6:] if i == 1: digit_str = value.replace('.', '/') return digit_str if i == 2: num = value + '0' return num def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_empty_columns(table)))" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_empty_columns(table): new_table = [] for i in range(len(table)): new_table.append([]) for j in range(len(table[i])): if table[i][j]: new_table[i].append(table[i][j]) return new_table def delete_duplicate_columns(table): for row in table: del row[2] return table def delete_duplicate_rows(table): new_table = [] for row in table: if row not in new_table: new_table.append(row) return new_table def transformer(i, value): if i == 0: return 'Да' if value == 'Выполнено' else 'Нет' if i == 1: return value.replace('[at]', '@') if i == 2: year = value.replace('.', '/') return year[:-4] + year[8:] def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_duplicate_columns(delete_empty_rows(delete_empty_columns(delete_duplicate_rows(table))))))" "def main(s): a = [] filtred = [] r_list = [] f_list = [[], [], [], []] for person in s: a = list(filter(None, person)) filtred.append(a) filtred = list(filter(None, filtred)) for person in filtred: if person not in r_list: r_list.append(person) for person in r_list: mailstr = person[0] i = 0 mst = '' while mailstr[i] != '[': mst += mailstr[i] i += 1 f_list[0].append(mst) datastr = person[1] f_list[1].append(datastr[6:] + datastr[2:6] + datastr[:2]) number_str = person[2] f_list[2].append(number_str[4:10] + '-' + number_str[10:12]) namestr = person[3] namestr = namestr.split() f_list[3].append(f'{namestr[0]} {namestr[2]}') return f_list" "def step1(table): for i in range(len(table)): del table[i][3] return table def num(table): number_list = [] number = [] number_list = list(table) number.append(number_list[0]) number.append(number_list[1]) number.append(' ') number.append(number_list[2]) number.append(number_list[3]) number.append(number_list[4]) number.append(' ') number.append(number_list[5]) number.append(number_list[6]) number.append(number_list[7]) number.append('-') number.append(number_list[8]) number.append(number_list[9]) number.append(number_list[10]) number.append(number_list[11]) number = ''.join(number) return number def sr(table): index = [] index_final = [] index = list(table) index_final.append(index[6]) index_final.append(index[7]) index_final.append(index[2]) index_final.append(index[3]) index_final.append(index[4]) index_final.append(index[5]) index_final.append(index[0]) index_final.append(index[1]) st = ''.join(index_final) return st def last(table): q = [] q_f = [] q = list(table) for g in range(len(q) - 2): q_f.append(table[g]) for i in range(len(q_f) - 1): if q_f[i] == ',': del q_f[i] table = ''.join(q_f) return table def step2(table): for i in range(len(table)): table[i][0] = num(table[i][0]) table[i][1] = sr(table[i][1]) table[i][2] = last(table[i][2]) return table def main(table): step1(table) return step2(table)" "def main(table): r_t = [list(tupl) for tupl in dict.fromkeys((tuple(item) for item in table))] r_t_2 = [i[0].split('&')[::-1] + i[1:] for i in r_t] for i in r_t_2: i[0] = i[0].replace('@', '[at]') i[1] = ' '.join([i[1][:2], i[1][2:5], '-'.join([i[1][5:8], i[1][8:10], i[1][10:12]])]) i[2] = i[2].lower() i[3] = i[3].replace('.', '-')[:6] + i[3][8:] return r_t_2" "from datetime import datetime import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] new_table = [] row1 = [] row2 = [] row3 = [] row4 = [] tpls = [tuple(x) for x in data if x[1] is not None] dct = list(dict.fromkeys(tpls)) data = [list(x) for x in dct] for i in data: split = i[0].split('|') i[0] = re.sub('.*\\[at\\]', '', split[1]) date = datetime.strptime(i[1], '%d/%m/%Y') i[1] = datetime.strftime(date, '%Y.%m.%d') split2 = i[2].split(' ') i[2] = str(round(float(split[0]), 2)).replace('0.', '') + '%' if len(i[2]) == 2: i[2] = i[2][0] + '0%' elif i[2][0] == '0': i[2] = i[2][1:] elif i[2] == '1.0%': i[2] = '100%' i.append(split2[0][:-1]) row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) row4.append(i[3]) new_table.append(row1) new_table.append(row2) new_table.append(row3) new_table.append(row4) return new_table" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('-') i[n] = f'{hop[2]}/{hop[1]}/{hop[0]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('Выполнено', 'Y') i[n] = i[n].replace('Не выполнено', 'N') return lst def format_procent(lst, n): for i in lst: j = float(i[n]) i[n] = '{0:.3f}'.format(j) return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = j[0] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n].replace(' ', '') return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('[at]')[0] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = splt(lst, 1, 1, sep=';') lst = true_format(lst, 0) lst = format_procent(lst, 3) lst = surname_format(lst, 2) lst = telephone_format(lst, 1) return lst" "from pprint import pprint def main(table): table = pustot(del_none(del_pov(table))) for j in range(len(table)): table[j][0] = table[j][0].replace('/', '.') table[j][0] = table[j][0][-2:] + table[j][0][2:6] + table[j][0][:2] table[j][1] = table[j][1].split(' ') table[j][1] = table[j][1][0] table[j][2] = table[j][2].replace('@', '[at]') table[j][3] = table[j][3][4:] return perevertish(bubblesort_by_number(table)) def perevertish(table): my_list_pers = [] my_list_data = [] my_list_name = [] my_list_tel = [] for row in range(len(table)): my_list_pers.append(table[row][0]) my_list_data.append(table[row][1]) my_list_name.append(table[row][2]) my_list_tel.append(table[row][3]) table = [my_list_pers, my_list_data, my_list_name, my_list_tel] return table def bubblesort_by_number(table): for item in range(0, len(table) - 1): for row in range(len(table) - 1): if table[row][3] > table[row + 1][3]: bubble = table[row] table[row] = table[row + 1] table[row + 1] = bubble return table def del_none(table): for row in table: if row == [None, None, None, None, None]: table.remove(row) return table def del_pov(table): table.reverse() for row in table: while table.count(row) != 1: table.remove(row) table.reverse() return table def pustot(table): for row in table: while row.count(None) != 0: row.remove(None) return table" "def main(source_list): buffer = [] for (indx, row) in enumerate(source_list): check = list(set(row)) check.remove(None) if check: buffer.append([]) row = list(filter(lambda a: a is not None, row)) for (num, col) in enumerate(row): if '.' in col and col[2:].isdigit(): buffer[-1].append(f'{str(round(float(col) * 100))}%') elif '+' in col: buffer[-1].append(col.replace('+', '').replace('-', '').replace(' ', '')[1:]) elif '.' in col: buffer[-1].append(col.split(' ')[0].strip()) else: buffer[-1].append(col.replace('-', '.')) buffer = [list(x) for x in zip(*buffer)] return buffer main([[None, '0.6527', None, '+7 559 806-21-26', 'Мизибский А.Н.', '06-01-99'], [None, '0.7637', None, '+7 727 052-08-47', 'Куценев Н.Н.', '14-03-04'], [None, '0.6922', None, '+7 469 806-21-41', 'Гидук М.Ц.', '20-09-03'], [None, None, None, None, None, None], [None, '0.9454', None, '+7 640 738-82-45', 'Рокудли О.Б.', '07-10-00']])" "def delete_empty_columns(table): for i in range(len(table)): table[i] = [cell for cell in table[i] if cell is not None] return table def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_rows(table): unique_list = [] for row in table: if row not in unique_list: unique_list.append(row) return unique_list def delete_duplicate_columns(table): for row in table: del row[4] return table def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def transformer(j, value): if j == 0: value = value.split('/') value = f'{value[2]}-{value[1]}-{value[0]}' elif j == 1: value = str(round(float(value), 3)) if len(value) == 4: value = value + '0' elif j == 2: value = value.split('[at]')[0] return value def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transpose(transform(delete_duplicate_rows(delete_empty_columns(delete_duplicate_columns(delete_empty_rows(table))))))" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0]] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(3) i.pop(2) i.pop(1) i[0] += '0' split = i[1].split('!') split2 = split[0].split(' ') i[1] = split2[2] i2 = i[2] date = datetime.strptime(split[1], '%d/%m/%Y') i[2] = datetime.strftime(date, '%d-%m-%y') i.append(i2.replace('-', '')) row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) row.append(i[3]) new_table.append(row) return new_table" "def main(v): for i in v: for j in i[:]: if j is None: i.remove(j) else: continue for i in v[:]: if len(i) == 0: v.remove(i) else: continue qw = [] for row in v: if row not in qw: qw.append(row) else: continue result = [] for row in qw: first = row[0] if first == 'Нет': first = 'N' else: first = 'Y' second = row[1] second = second[second.find('('):] third = row[3] third = third.replace('-', '/') third = third[6:] + third[2:6] + third[:2] tmp = [] tmp.append(first) tmp.append(second) tmp.append(third) result.append(tmp) return result" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_rows(table): dict = {x[0]: x for x in table} table = list(dict.values()) return table def transform(table): table.append([None for x in table[0]]) (table[2], table[3]) = (table[3], table[2]) for i in range(len(table[0])): table[2][i] = table[0][i][0:10] atInd = table[0][i].find('[at]') table[0][i] = table[0][i][11:atInd] for i in range(len(table[1])): table[1][i] = table[1][i][9:15] + table[1][i][16:] for i in range(len(table[2])): table[2][i] = table[2][i].replace('-', '/') for i in range(len(table[3])): name = table[3][i].split() table[3][i] = f'{name[1]} {name[0]}' return table def main(table): return transform(delete_empty_rows(transpose(delete_duplicate_rows(table))))" "import re def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): for row in table: del row[4] return table def delete_duplicate_rows(table): table1 = [] for row in table: if row not in table1: table1.append(row) return table1 def transformer(i, value): if i == 0: value = re.sub('(20|19)(\\d+)', '\\2', value) replaced = value.replace('-', '.') return replaced[0:] if i == 1: replaced = value.replace('(', '').replace(')', '') return replaced[0:] if i == 2: name = value.split() return f'{name[2]}' if i == 3: return 'Y' if value == 'Выполнено' else 'N' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def sort_by_row(table): table.sort(key=lambda k: k[1]) return table def main(table): return transform(transpose(sort_by_row(delete_duplicate_columns(delete_duplicate_rows(delete_empty_rows(table))))))" "def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(-1) i.pop(-1) i.pop(-1) i[0] = str(round(float(i[0]), 1)) i[1] = i[1][4:10] + '-' + i[1][10:] i[2] = i[2].replace(',', '')[:-2] row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) new_table.append(row) return new_table" "import re def proceed(oRow): mail = [] row = [] criteria = [] row.append(formDate(*oRow[0].split('-'))) row.append(extractor(oRow[2])) row.append(extractor1(oRow[2])) row.append(extractor2(oRow[5])) return row def formDate(first, second, third): return third + '-' + second + '-' + first def extractor(row): mail = re.split('@', row) mail = mail[1].split('|') return mail[0] def extractor1(row): mail = re.split('@', row) mail = mail[1].split('|') if mail[1] == 'Не выполнено': mail[1] = 'N' else: mail[1] = 'Y' return mail[1] def extractor2(row): criteria = row[:6] + row[7:] return criteria def main(table): newTable = [] for i in range(0, len(table)): newTable.append(proceed(table[i])) return newTable" "def matrix_transpose(matrix): trans_matrix = [[0 for j in range(len(matrix))] for i in range(len(matrix[0]))] for i in range(len(matrix)): for j in range(len(matrix[0])): trans_matrix[j][i] = matrix[i][j] return trans_matrix def matrix_sort(matrix): key_array = [] sorted_matrix = [] letter_array = [] for line in matrix: key_array.append(line[0]) key_array = set(key_array) key_array = list(key_array) key_array.sort() for elem in key_array: for line in matrix: if elem in line: sorted_matrix.append(line) break return sorted_matrix def main(table): matrix = [] string_matrix = [] for string in table: count = 1 for elem in string: if not elem: continue if count == 1: elem = elem.replace('@', '[at]') string_matrix.append(elem) count += 1 continue if count == 2: elem = str(round(float(elem), 1)) string_matrix.append(elem) count += 1 continue if count == 3: elem = elem.replace('-', '.') string_matrix.append(elem) count += 1 continue if count == 4: if 'Не выполнено' in elem: elem = elem.replace('Не выполнено', 'N') else: elem = elem.replace('Выполнено', 'Y') string_matrix.append(elem) count += 1 continue if string_matrix: matrix.append(string_matrix) string_matrix = [] matrix = matrix_sort(matrix) matrix = matrix_transpose(matrix) return matrix" "def main(a: list): for i in range(len(a)): date = a[i][0].split(':') a[i][0] = date[1].replace('-', '.') a[i][1] = a[i][1].replace('[at]', '@') a[i][2] = 'Y' if a[i][2] == 'true' else 'N' a[i][3] = date[0] + '00' a.sort(key=lambda date: date[0]) res = [[], [], [], []] for i in range(4): for j in range(len(a)): res[i].append(a[j][i]) return res" "from datetime import datetime import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[2] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(0) i.pop(0) split = i[0].split('|') i[0] = re.sub('.*@', '', split[0]) date = datetime.strptime(i[1], '%d/%m/%y') i[1] = datetime.strftime(date, '%d-%m-%y') if i[2] == 'Не выполнено': i[2] = 'Нет' else: i[2] = 'Да' i.append(split[1][6:].replace('-', '')) row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) row.append(i[3]) new_table.append(row) return new_table" "def main(mass): mass = dupremove(mass) returnTable = [] for i in range(0, len(mass)): returnRow = [] if mass[i][0] is not None: returnRow.append(mass[i][0].split(';')[1][:-2]) returnRow.append(parseBinary(mass[i][1])) returnRow.append(mass[i][4].replace('.', '-')) returnRow.append(parseFloat(mass[i][0].split(';')[0])) returnTable.append(returnRow) return [list(x) for x in zip(*returnTable)] def parseBinary(str): if str == 'N': return '0' else: return '1' def dupremove(ls): res = [] for i in ls: if i not in res: res.append(i) return res def parseFloat(st): return str(round(round(float(st), 2) * 100)) + '%'" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0]] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(3) i[0] = '(' + i[0][0:3] + ') ' + i[0][4:10] + '-' + i[0][10:] split = i[1].split(' ') i[1] = split[0] i[2] = str(round(float(i[2]), 3)) if len(i[2]) == 4: i[2] += '0' date = datetime.strptime(i[3], '%d.%m.%Y') i[3] = datetime.strftime(date, '%d-%m-%Y') row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) row.append(i[3]) new_table.append(row) return new_table" "def main(lis): name = '' name2 = '' for row in lis: del row[2] for i in range(len(lis)): s = lis[i][0] s = s.replace('@', '[at]') lis[i][0] = s s = lis[i][1] s = s.replace('+7 ', '') lis[i][1] = s s = lis[i][2] name = s[0:s.find(' ')] name2 = s[s.find(' ') + 1:s.find(' ') + 3] lis[i][2] = name2 + ' ' + name s = lis[i][3] if s == 'Да': lis[i][3] = '1' else: lis[i][3] = '0' return lis" "def main(kek): temp = None state = 1 for lst in kek: state = 1 for string in lst: if string is not None: state = 0 if state == 1: kek.remove(lst) i = 0 for lst in kek: j = 0 for string in lst: if string is None: kek[i].pop(j) j += 1 i += 1 i = 0 for lst in kek: kek[i][0] = str(int(lst[0][-1]) * 10) + '%' kek[i][1] = lst[1].replace('@', '[at]') kek[i].pop(3) if lst[2] == 'N': kek[i][2] = 'false' else: kek[i][2] = 'true' i += 1 return kek" "def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): for row in table: del row[1] del row[1] return table def delete_duplicate_rows(table): result = [] for i in table: if i not in result: result.append(i) return result def transformer(value): temp = value[0].split('|') if temp[1] == 'Да': value.append('Выполнено') else: value.append('Не выполнено') temp = temp[0].split(' ') temp[0] = temp[0][0] + '.' value[0] = temp[2] + ' ' + temp[0] + temp[1] temp1 = value[1].split('[') value[1] = temp1[0] temp2 = value[2].split(')') value[2] = temp2[1] return value def transform(table): for i in range(len(table)): table[i] = transformer(table[i]) return table def peremena(table): for i in range(len(table)): (table[i][0], table[i][3]) = (table[i][3], table[i][0]) return table def main(table): return peremena(transform(delete_duplicate_rows(delete_duplicate_columns(delete_empty_rows(table)))))" "def one(a1): a1 = a1[4:19] b1 = a1[0:3] + ' ' + a1[5:11] + a1[12:14] return b1 def two(a2): if a2 == '1': return 'да' else: return 'нет' def three(a3): i = 0 while a3[i] != '[': i = i + 1 a3 = a3[0:i] return a3 def four(a4): a4 = a4[25:27] + '/' + a4[22:24] + '/' + a4[19:21] return a4 def main(s): x = 0 q1 = [] q2 = [] q3 = [] q4 = [] while x < len(s): if s[x][1] is None: x = x + 1 else: oo = one(str(s[x][0])) q1.append(oo) oo = four(str(s[x][0])) q4.append(oo) oo = two(str(s[x][1])) q2.append(oo) oo = three(str(s[x][2])) q3.append(oo) x = x + 1 if x >= len(s): q = [q1, q2, q3, q4] break return q" "def delete_duplicate_columns(table): for row in table: del row[3] del row[3] return table def split_col(table): for row in table: var = row[1].split('#') row[0] = str(int(float(var[0]) * 100)) + '%' if var[1] == 'Да': row[1] = 'Y' elif var[1] == 'Нет': row[1] = 'N' return table def transform(table): for row in table: row[3] = row[3].replace(' ', '(', 1) row[3] = row[3].replace(' ', ')', 1) buf = row[2].split('-') buf[0] = buf[0][2:4] row[2] = buf[2] + '/' + buf[1] + '/' + buf[0] return table def main(table): table = delete_duplicate_columns(table) table = split_col(table) table = transform(table) return table" "def delete_empty_rows(table): return [row for row in table if row[1] is not None] def delete_duplicate_columns(table): for row in table: del row[0] del row[3] return table def transformer(i, value): if i == 0: return 'Выполнено' if value == 'да' else 'Не выполнено' if i == 1: return value + '0' if i == 2: return value[3:] def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(delete_duplicate_columns(delete_empty_rows(table)))" "def deleteEmty(table): for i in range(len(table)): if table[i][0] is None: table[i] = 0 for i in range(table.count(0)): table.remove(0) for i in range(len(table)): table[i][0] = table[i][0].split('!') for i in range(len(table)): table[i].append(table[i][0][0].replace('-', '.')) for i in range(len(table)): table[i][0] = table[i][0][1][9:] for i in range(len(table)): table[i][2] = table[i][2].split()[1] for i in range(len(table)): table[i][1] = table[i][1].split('[at]', 1)[0] for i in range(len(table)): (table[i][2], table[i][3]) = (table[i][3], table[i][2]) return table def main(table): return deleteEmty(table)" "def del_row(s): s1 = [] for row in s: if row not in s1: s1.append(row) return s1 def transpose(s): s1 = [] for i in range(len(s[0])): s1.append([]) for j in range(len(s)): s1[i].append(s[j][i]) return s1 def main(s): s = [row for row in s if row[0] is not None] s = del_row(s) s = transpose(s) s = [row for row in s if row[0] is not None] s = del_row(s) s = transpose(s) for row in s: row[0] = 'Да' if row[0] == 'Y' else 'Нет' row[1] = '/'.join(reversed(row[1].split('/'))) row[2] = row[2].split('.')[0].replace(',', '') + '.' row[3] = row[3].split('@')[1] return s" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('-') i[n] = f'{hop[2]}/{hop[1]}/{hop[0]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('Выполнено', 'true') i[n] = i[n].replace('Не выполнено', 'false') return lst def format_procent(lst, n): for i in lst: j = float(i[n]) i[n] = '{0:.3f}'.format(j) return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = j[1] + ' ' + j[0] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n].replace(' ', '') return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('[at]')[0] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = splt(lst, 1, 2, sep=':') lst = true_format(lst, 2) lst = format_procent(lst, 1) lst = surname_format(lst, 0) lst = transpose(lst) return lst" "def main(mass): mass = dupremove(mass) returnTable = [] for i in range(0, len(mass)): returnRow = [] returnRow.append(numberParse(mass[i][1])) returnRow.append(mass[i][4].split('@')[1].split('!')[0]) returnRow.append(parseText(mass[i][4].split('@')[1].split('!')[1])) returnTable.append(returnRow) return returnTable def dupremove(ls): res = [] for i in ls: if i not in res: res.append(i) return res def parseText(str): if str == 'Не выполнено': return 'Нет' else: return 'Да' def numberParse(str): return str[0] + str[1] + str[2] + '-' + str[3] + str[4] + str[5] + '-' + str[6] + str[7] + str[8] + str[9]" "def main(table): result = [] for row in table: if row[0] is None: continue tempRow = [] col1 = row[0][:row[0].find('!')] col11 = col1[col1.find('.') + 2:] + ' ' + col1[:1] col11 += '.' + col1[col1.find('.') - 1:col1.find('.') + 1] tempRow.append(col11) tempRow.append(row[0][row[0].find('[at]') + 4:]) col2 = row[1][0:15].replace('(', '').replace(')', '') col2 = col2.replace('-', '%', 1) tempRow.append(col2.replace('-', '').replace('%', '-')) col4 = '{0:.4f}'.format(float(row[4].replace('%', '')) / 100, '-2f') tempRow.append(col4) result.append(tempRow) result = sortT(transpouse(result)) return result def transpouse(mat): matrix = [] for i in range(len(mat[0])): matrix.append(list()) for j in range(len(mat)): matrix[i].append(mat[j][i]) return matrix def sortT(table): map = {} for i in range(len(table[2])): map[i] = table[2][i] sorted_values = sorted(map.values()) sorted_dict = {} for i in sorted_values: for k in map.keys(): if map[k] == i: sorted_dict[k] = map[k] break keys = [] for i in sorted_dict.keys(): keys.append(i) matrix = [] for i in range(len(table)): arr = [] for j in range(len(table[2])): arr.append(table[i][keys[j]]) matrix.append(arr) return matrix" "def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_empty_columns(table): for row in table: del row[2] for row in table: del row[2] return table def delete_duplicate_columns(table): for row in table: del row[4] return table def transformer(i, value): if i == 0: replaced = value.replace('/', ' ') dat = replaced.split() return f'{dat[2][-2:]}.{dat[1]}.{dat[0]}' if i == 1: name = value.split() return f'{name[1][:-2]} {name[0][:-1]}' if i == 2: replaced = value.replace('-', ' ') num = replaced.split() return f'({num[0]}) {num[1]}-{num[2][:-2]}-{num[2][-2:]}' if i == 3: return 'Выполнено' if value == '1' else 'Не выполнено' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(delete_duplicate_columns(delete_empty_rows(delete_empty_columns(table))))" "import datetime def delete_column(input_list, delete_index): for a in input_list: a.pop(delete_index) return input_list def transpon(input_list): output_list = [] for j in range(0, len(input_list[0])): o_list = [] for i in range(0, len(input_list)): o_list.append(input_list[i][j]) output_list.append(o_list) return output_list def delete_doubles(input_list): for i in range(0, len(input_list)): input_list[i] = list(dict.fromkeys(input_list[i])) return input_list def separate_columns(input_list): for element in input_list: for a in range(0, len(element)): if '#' in element[a]: strings = element[a].split('#') if strings[0] == 'нет': element[a] = 'false' else: element[a] = 'true' element.insert(a, strings[1].split('@')[1]) return input_list def convert_to_date(input_list): for i in range(0, len(input_list)): for j in range(0, len(input_list[0])): e = input_list[i][j] try: e = datetime.datetime.strptime(e, '%Y.%m.%d').strftime('%d.%m.%Y') except ValueError: continue input_list[i][j] = e return input_list def convert_to_percents(input_list): for i in range(0, len(input_list)): for j in range(0, len(input_list[0])): if '.' in input_list[i][j]: e = 0 try: e = float(input_list[i][j]) except ValueError: continue input_list[i][j] = str(int(e * 100)) + '%' return input_list def delete_empty_columns(input_list): for a in range(len(input_list)): input_list[a] = list(filter(None, input_list[a])) return input_list def main(input_list): output_list = delete_empty_columns(input_list) output_list = delete_doubles(output_list) output_list = separate_columns(output_list) output_list = convert_to_percents(output_list) output_list = convert_to_date(output_list) output_list = transpon(output_list) return output_list" "def main(a: list): i = 0 while i < len(a): if a[i][0] is None: del a[i] else: del a[i][2] del a[i][2] del a[i][2] a[i][0] = a[i][0] + '0' a[i][1] = a[i][1][a[i][1].find(']') + 1:] name = a[i][2].split(' ') a[i][2] = name[1] + ' ' + name[0] a[i][3] = a[i][3][7:] i += 1 return a" "def main(table): b = [] for h in table: if h not in b: b.append(h) tosort = {} for i in range(len(b)): tmp = b[i][0].split() b[i][0] = tmp[2] + ' ' + tmp[0][0] + '.' + tmp[1] b[i][1] = b[i][1].replace('Y', '1').replace('N', '0') b[i][2] = b[i][2].split('[at]')[1] b[i][3] = b[i][3][5:] tosort[b[i][0]] = b[i] tosort = dict(sorted(tosort.items())) b = list(tosort.values()) return b" "from typing import Dict, List def remove_empty(lst: List[List[str]]) -> None: if len(lst) == 1: if any(lst): return lst else: return [] for i in range(len(lst) - 1, -1, -1): if not any(lst[i]) or not lst[i]: lst.pop(i) def transform_mail(lst: List[List[str]]) -> None: for i in range(len(lst)): if lst[i][3]: lst[i][1] = 'да' if lst[i][3] == 'true' else 'нет' for i in range(len(lst)): lst[i][3] = lst[i][4].replace('[at]', '@') lst[i].pop(4) def transform_date(lst: List[List[str]]) -> None: for i in range(len(lst)): if lst[i][0]: temp: List[str] = lst[i][0].split('!') if len(temp) == 1: number: str = temp[0] lst[i][2] = number.replace(' ', '-') else: number: str = temp[0] date: str = temp[1] date = '/'.join(date.split('-')[::-1]) number = number.replace(' ', '-') lst[i][0] = date lst[i][2] = number def main(table: List[List[str]]) -> List[List[str]]: remove_empty(table) transform_mail(table) transform_date(table) return table" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_cols(table): for row in table: del row[2] return table def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_rows(table): new_table = [] for row in table: if row not in new_table: new_table.append(row) return new_table def transformer(i, value): if i == 0: return 'Выполнено' if value == 'Y' else 'Не выполнено' if i == 1: value = float(value) return f'{value:.4f}' if i == 2: name = value.split() return f'{name[1]} {name[0]}' if i == 3: date = value.split('.') return f'{date[2]}/{date[1]}/{date[0]}' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_empty_rows(delete_duplicate_rows(delete_empty_cols(table)))))" "def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(-1) split = i[0].split(' ') i[0] = split[1] + ' ' + split[0][:-2] split = i[1].split('#') i[1] = split[1] + '0' if i[2] == 'Выполнено': i[2] = 'Да' else: i[2] = 'Нет' i.append(split[0].replace('+7', '').replace(' ', '').replace('-', '')) row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) row.append(i[3]) new_table.append(row) return new_table" "def main(oldstring): string = [] for i in oldstring: flag = True for j in string: if i == j: flag = False if flag: string.append(i) cell1 = [] cell2 = [] cell3 = [] cell4 = [] for i in string: cell1.append(i[0].replace('/', '.')) name = i[2].partition('&')[2] surname = name.partition(' ')[2].partition(' ')[2] name = name.partition(' ')[0] name = surname + ' ' + name cell2.append(name) cell3.append(i[3].replace('@', '[at]')) number = i[2].partition('&')[0].partition('+7')[2] number = number[:3] + '-' + number[3:] number = number[:7] + '-' + number[7:] cell4.append(number) newvar = [cell1, cell2, cell3, cell4] return newvar" "import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(1) i.pop(-1) split = i[0].split(';') split1 = split[0].split(' ') i[0] = split1[2] + ', ' + split1[0][0] + '.' + split1[1] i1 = i[1] i[1] = str(round(float(split[1]), 2)) + '%' i[1] = i[1].replace('0.', '') if len(i[1]) == 2: i[1] = str(round(float(split[1]), 2)) + '0%' i[1] = i[1].replace('0.', '') elif i[1][0] == '0': i[1] = i[1][1:] elif i[1] == '1.0': i[1] = '100%' i.append(re.sub('.*\\[at\\]', '', i1)) row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) new_table.append(row) new_table.sort() return new_table" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] new_table = [] row1 = [] row2 = [] row3 = [] row4 = [] for i in data: i.pop(2) i.pop(0) i[0] = i[0][7:13] + i[0][14:] split = i[1].split(';') date = datetime.strptime(split[1], '%d-%m-%y') i[1] = datetime.strftime(date, '%d/%m/%y') if i[2] == '1.0': i[2] = '100%' elif i[2] == '0.0': i[2] = '0%' else: i[2] = i[2].replace('0.', '') + '0%' if split[0] == 'Нет': i.append('N') else: i.append('Y') row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) row4.append(i[3]) new_table.append(row1) new_table.append(row2) new_table.append(row3) new_table.append(row4) return new_table" "import re def main(my_list): table = [] for i in my_list: if i not in table: table.append(i) result = [] for i in range(len(table)): if table[i][0] is not None: phone = re.findall('(?<=\\) )([\\s\\S]+?)(?=\\&)', table[i][0]) mail = table[i][1].replace('[at]', '@') date = re.findall('\\&(.*)', table[i][0]) date1 = date[0][8:] date2 = date[0][:-3][5:] date3 = date[0][:-6] date_res = date1 + '/' + date2 + '/' + date3 abc = [phone[0], mail, date_res] result.append(abc) return result" "def delete_duplicate(table): for i in range(0, len(table)): j = i + 1 while j < len(table): if table[i] == table[j]: del table[j] j += 1 return table def delete_empty_rows(table): return [row for row in table if row[0] is not None] def split(table): for i in range(0, len(table)): table[i].append(table[i][1][table[i][1].find('|') + 1:]) return table def transform(table): for i in range(0, len(table)): a = table[i][0][:table[i][0].find(' ')] b = table[i][0][table[i][0].find(' ') + 1] + '.' table[i][0] = b + ' ' + a table[i][1] = table[i][1][:table[i][1].find('|')] + '0' table[i][2] = table[i][2].replace('.', '/') return table def main(table): table = delete_empty_rows(table) table = delete_duplicate(table) table = split(table) table = transform(table) return table" "def main(a: list): for i in range(len(a)): a[i][0] = a[i][0].replace('[at]', '@') a[i][1] = a[i][2][2:5] + ' ' + a[i][2][5:8] + '-' + a[i][2][-4:] cell = a[i][3].split(';') a[i][2] = 'Y' if cell[0] == 'да' else 'N' if len(cell[1]) == 3: a[i][3] = '0.' + cell[1][:2] + '00' else: a[i][3] = '0.0' + cell[1][:1] + '00' return a" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def transformer(i, value): if i == 0: return value[0:2] + ' ' + value[4:7] + ' ' + (value[9:12] + '-' + value[13:15] + value[16:18]) if i == 1: return value.split('[at]')[0] if i == 2: return value.title() if i == 3: return value.replace('/', '-') def transform(table): for j in range(len(table)): for i in range(len(table[j])): table[j][i] = transformer(i, table[j][i]) return table def remove_empty_rows(table): newTable = [] for i in table: if i[0] is not None: newTable.append(i) return newTable def remove_duplicate_rows(table): newTable = [] for i in table: if i not in newTable: newTable.append(i) return newTable def remove_duplicate_cols(table): for row in table: del row[1] return table def main(table): return transpose(transform(remove_empty_rows(remove_duplicate_rows(remove_duplicate_cols(table)))))" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_duplicate_columns(table): for row in table: del row[2] return table def delete_empty_rows(table): return [row for row in table if row[0] is not None] def transformer(i, value): if i == 0: name = value.split(':')[1] names = name.split(' ') return names[2] + ' ' + names[0][:1] + '.' + names[1] if i == 1: name = value.split(':')[0].replace('.', '') return name[4:] + '-' + name[2:4] + '-' + name[:2] if i == 2: if value == '1': return 'Выполнено' else: return 'Не выполнено' def transform(table): newTab = [] for i in range(len(table)): newTab.append([]) for j in range(len(table[i])): if j != 0: newTab[i].append(transformer(2, table[i][j])) else: newTab[i].append(transformer(0, table[i][j])) newTab[i].append(transformer(1, table[i][j])) return newTab def sorter(table): dict = {} for i in range(len(table)): value = table[i][1].replace(' ', '').replace('-', '') dict[value] = i lst = [] for i in sorted(dict.items()): lst.append(i[1]) return lst def sort(table): order = sorter(table) tab = [] for i in order: tab.append(table[i]) return tab def main(table): return transpose(sort(transform(delete_empty_rows(delete_duplicate_columns(table)))))" "def main(tab): tab = [row for row in tab if row[0] is not None] for i in range(0, len(tab)): tab[i] = [row for row in tab[i] if row is not None] for i in range(0, len(tab)): tab[i][0] = tab[i][0].replace(' ', '-') for i in range(0, len(tab)): tab[i][1] = str('{0:.2f}'.format(round(float(tab[i][1]), 2))) for i in range(0, len(tab)): tab[i][2] = tab[i][2].replace('-', '.') tab[i][2] = tab[i][2][0:6] + tab[i][2][8:10] return tab" "def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0]] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] row1 = [] row2 = [] row3 = [] row4 = [] for i in data: i.pop(-1) i.pop(2) split = i[0].split('#') i[0] = split[1].replace('[at]', '@') i[1] = '(' + i[1][3:6] + ') ' + i[1][7:] i2 = i[2] split1 = split[0].split(' ') i[2] = split1[1] if i2 == 'Выполнено': i.append('Да') else: i.append('Нет') row = [] row.append(i[2]) row.append(i[1]) row.append(i[0]) row.append(i[3]) new_table.append(row) new_table.sort() for i in new_table: (i[0], i[2]) = (i[2], i[0]) row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) row4.append(i[3]) new_table1 = [] new_table1.append(row1) new_table1.append(row2) new_table1.append(row3) new_table1.append(row4) return new_table1" "def main(nbook): n2 = [] for i in nbook: if i not in n2 and i[1] is not None: n2.append(i) n3 = [] for i in range(0, len(n2)): if n2[i][1] == 'N': stroka1 = 'нет' else: stroka1 = 'да' stroka2 = round(float(n2[i][2]) * 100) stroka2 = str(stroka2) + '%' stroka = n2[i][4].split('-') stroka3 = stroka[-1] + '-' + stroka[-2] + '-' stroka3 += stroka[0][-2] + stroka[0][-1] stroka4 = n2[i][5].split('@') stroka4 = stroka4[1] n3.append([stroka1, stroka2, stroka3, stroka4]) nbook = [] for i in range(0, len(n3[0])): stroka = [] for j in range(len(n3)): stroka.append(n3[j][i]) nbook.append(stroka) return nbook" "def delete_duplicate_empty_columns(table): for row in table: del row[1] del row[1] del row[3] return table def delete_duplicate_rows(table): i = 0 while i < len(table) - 1: j = i + 1 while j < len(table): if table[i] == table[j]: del table[j] else: j += 1 i += 1 return table def format_num(num): if num < 10: return '0.0' + str(num * 10) return '0.' + str(num * 10) def format_row(row): new_row = [] new_row.append(row[0][0:10]) new_row[0] = f'{new_row[0][0:2]}-{new_row[0][3:5]}-{new_row[0][8:10]}' new_row.append(row[0][11:]) new_row.append(row[1].split(' ')[2] + ' ' + row[1].split(' ')[0]) new_row.append(format_num(int(row[2][0:-1]))) if new_row[1] == 'да': new_row[1] = 'Y' else: new_row[1] = 'N' return new_row def transform(table): new_table = [] for row in table: new_table.append(format_row(row)) return new_table def main(table): return transform(delete_duplicate_rows(delete_duplicate_empty_columns(table)))" "def main(s): q = 0 w = 0 e = 0 p = 0 a = [] filtred = [] r_list = [] f_list = [[], [], [], []] for person in s: a = list(filter(None, person)) filtred.append(a) filtred = list(filter(None, filtred)) for person in filtred: if person not in r_list: r_list.append(person) for person in r_list: number_ph = person[0] i = 0 mst = '' while number_ph[i] != '#': i += 1 i = 1 + i while i < len(number_ph): mst += number_ph[i] i += 1 replaced = mst.replace('-', '').replace(' ', '') f_list[q].append(replaced) q = 1 + q numstr = person[1] f_list[w].append(numstr + '00') w = 1 + w mailstr = person[0] i = 0 mst = '' while mailstr[i] != '.': mst += mailstr[i] i += 1 mst += '.' f_list[e].append(mst) e = e + 1 datastr = person[2] f_list[p].append(datastr[8:10] + '-' + datastr[3:5] + '-' + datastr[0:2]) p = p + 1 f_list = list(filter(None, f_list)) return f_list" "def main(table): result = [] dict = [] for row in table: if row in dict: continue if row[0] is None: continue dict.append(row) tempRow = [] col1 = '{0:.1f}'.format(float(row[0])) tempRow.append(col1) tempRow.append(row[1].replace('@', '[at]')) tempRow.append(row[3][2:]) if row[4] == 'да': tempRow.append('Да') else: tempRow.append('Нет') result.append(tempRow) return result" "def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0]] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] row1 = [] row2 = [] row3 = [] for i in data: i.pop(1) split = i[0].split(' ') i[0] = split[1] split = i[1].split('#') i[1] = split[0][3:6] + '-' + split[0][7:] if split[1] == 'Выполнено': i.append('Да') else: i.append('Нет') row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) new_table.append(row1) new_table.append(row2) new_table.append(row3) return new_table" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_duplicate_columns(table): for row in table: del row[2] return table def delete_duplicate_rows(table): i = 0 while i < len(table): j = i + 1 while j < len(table): if table[j] == table[i]: del table[j] else: j += 1 i += 1 return table def transform(table): for i in table: if i[0] == '0': i[0] = 'N' else: i[0] = 'Y' i[1] = '-'.join(i[1].split('.')) a = i[2].split(', ') i[2] = ' '.join([a[1][:-2], a[0]]) return table def main(table): table = delete_duplicate_rows(delete_duplicate_columns(table)) return transpose(transform(table))" "def main(matrix): count = [] names = [] phones = [] confirmed = [] for info in matrix: if not info: continue validated = True for i in info: if not i: validated = False if not validated: continue c_count = '{:.2f}'.format(round(float(info[0].split(':')[1]), 2)) c_number = info[0].split(':')[0].replace('-', '') c_name = info[1].split('@')[0] if info[2] == 'Y': c_confirmed = 'true' else: c_confirmed = 'false' if c_name not in names: count.append(c_count) phones.append(c_number) names.append(c_name) confirmed.append(c_confirmed) return [count, names, phones, confirmed]" "def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): for row in table: del row[4] return table def delete_duplicate_rows(table): result = [] for i in table: if i not in result: result.append(i) return result def transformer(i, value): if i == 0: return 'true' if value == 'Y' else 'false' if i == 1: value = value.split('-') return value[2] + '-' + value[1] + '-' + value[0] if i == 2: name = value.split('[') return name[0] if i == 3: if int(value[-1]) > 5: value = float(value) + 0.01 return str(value)[:4] def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(delete_duplicate_rows(delete_duplicate_columns(delete_empty_rows(table))))" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(0) date = datetime.strptime(i[0], '%d/%m/%y') i[0] = datetime.strftime(date, '%y-%m-%d') i[1] = i[1].replace(' ', '').replace(')', '').replace('(', '').replace('-', '') split = i[2].split(' ') i[2] = split[1][:-2] + ' ' + split[0] row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) new_table.append(row) return new_table" "def transpose(table): response = [] for i in range(len(table[2])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[2] is not None] def delete_duplicate_columns(table): for column in table: del column[0] return table def transformer(i, j, value, table): if i == 0: forione = table[1][j].split('|') ionedate = forione[0].split('-') return f'{ionedate[2][2:]}/{ionedate[1]}/{ionedate[0]}' if i == 1: foritwo = table[1][j].split('|') proc = foritwo[1].replace('%', '') x = int(proc) / 100 return format(x, '.3f') if i == 2: return ('Да', 'Нет')[value != 'Выполнено'] def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, j, table[i][j], table) return table def main(table): return transform(transpose(delete_duplicate_columns(delete_empty_rows(table))))" "import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] row1 = [] row2 = [] row3 = [] row4 = [] for i in data: i.pop(4) i.pop(3) i.pop(1) i[0] = re.sub('@.*', '', i[0]) if i[1] == '1.0': i[1] = '100%' elif i[1] == '0.0': i[1] = '0%' else: i[1] = i[1].replace('0.', '') + '0%' split = i[2].split(' ') i[2] = split[1][:-2] + ' ' + split[0] i[3] = i[3][3:6] + '-' + i[3][7:13] + i[3][14:] row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) row4.append(i[3]) new_table.append(row1) new_table.append(row2) new_table.append(row3) new_table.append(row4) return new_table" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('.') i[n] = f'{hop[0]}-{hop[1]}-{hop[2]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('Выполнено', 'true') i[n] = i[n].replace('Не выполнено', 'false') return lst def format_procent(lst, n): for i in lst: j = float(i[n]) i[n] = '{0:.3f}'.format(j) return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = j[1] + ' ' + j[0] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n].replace('(', ' (') i[n] = i[n].replace(')', ') ') return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('[at]')[0] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = format_data(lst, 1) lst = email_format(lst, 2) lst = telephone_format(lst, 0) lst.sort(key=lambda x: x[0]) return lst" "def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): for row in table: del row[2] return table def delete_duplicate_rows(table): dict = {x[0]: x for x in table} table = list(dict.values()) return table def transform(table): for row in table: name = row[0].split() row[0] = name[1] atInd = row[1].find('[at]') + 4 row[1] = row[1][atInd:] date = row[2].split('.') row[2] = f'{date[2]}-{date[1]}-{date[0]}' return table def main(table): return transform(delete_empty_rows(delete_duplicate_columns(delete_duplicate_rows(table))))" "def main(x): for i in x: for j in i[:]: if j is None: i.remove(j) else: continue for i in x[:]: if len(i) == 0: x.remove(i) else: continue hg = [] for row in x: tmp = [] idk1 = row[0] idk2 = row[0] idk3 = row[1] idk4 = row[2] idk1 = idk1[:idk1.find(' ')] if idk3 == 'true': idk3 = 'Да' else: idk3 = 'Нет' xx = idk4 xx = sq(idk4) idk2 = idk2[idk2.find(']') + 1:] tmp.append(idk1) tmp.append(idk3) tmp.append(xx) tmp.append(idk2) hg.append(tmp) hg.sort(key=lambda i: i[0]) hg = list(map(list, zip(*hg))) return hg def sq(state): if state[2] == '0' and state[0] != '1': x = '0%' return x elif state[0] == '1': x = '100%' return x else: x = state[2] + '0%' return x" "from datetime import datetime import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] new_table = [] for i in data: i.pop(3) i.pop(0) split = i[0].split(';') split1 = split[0].split(' ') i[0] = split1[2] + ' ' + split1[0] date = datetime.strptime(i[1], '%Y/%m/%d') i[1] = datetime.strftime(date, '%y.%m.%d') i[2] = re.sub('.*\\[at\\]', '', i[2]) i.append(split[1][7:]) row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) row.append(i[3]) new_table.append(row) return new_table" "def delete_empty_columns(table): for c in table: c.pop(0) return table def delete_empty_rows(table): for r in table: if r == [None, None, None]: table.remove(r) return table def r_column(table): for r in table: r[2] = float(r[2]) r[2] = round(r[2], 1) r[2] = str(r[2]) return table def row_split(table): for r in table: r.append(r[1].split('|')[0]) r[1] = r[1].split('|')[1] return table def replacement(table): for r in table: r[0] = r[0].replace('Не выполнено', 'Нет').replace('Выполнено', 'Да') r[1] = r[1].replace('/', '-')[2:] (a, b) = r[3].split(' ') r[3] = b + ' ' + a return table def delete_duplicate(table): index = 1 while index < len(table): if table[index] in table[:index]: table.pop(index) else: index += 1 return table def main(table): delete_empty_columns(table) delete_empty_rows(table) r_column(table) row_split(table) replacement(table) delete_duplicate(table) return table" "from collections import OrderedDict from itertools import groupby def remove_duplicated_rows(lst): return list(OrderedDict(((tuple(x), x) for x in lst)).values()) def remove_empty_columns(lst): data = zip(*lst) data = [x for x in data if any(x)] return list(map(list, zip(*data))) def transpose(lst): return list(map(list, zip(*lst))) def remove_duplicated_columns(lst): data = zip(*lst) data = [x for x in data if not all_equal(x)] return list(map(list, zip(*data))) def all_equal(iterable): g = groupby(iterable) return next(g, True) and (not next(g, False)) def remove_empty_rows(lst): s = [] for ls in lst: if not all_equal(ls) and (not ls[0] is None): s.append(ls) return s def split_column_one_and_transform(lst): for ls in lst: s1 = ls[2].split('!') number = f'{s1[1][0:2]} {s1[1][2:5]} {s1[1][5:8]}-{s1[1][8:]}' percent = float(s1[0][:-1]) / 100 ls[0] = ls[0][:2] + ls[0][4:] ls[1] = number ls[2] = '{:.2f}'.format(percent) return sorted(lst, key=lambda x: x[0]) def main(lst): lst = remove_duplicated_rows(lst) lst = remove_empty_rows(lst) lst = split_column_one_and_transform(lst) lst = transpose(lst) return lst" "def row_split(table): for r in table: r.append(r[0].split('|')[1]) r[0] = r[0].split('|')[0].replace('-', '/') r[1] = r[1].split('[at]')[0] return table def r_round(table): for r in table: r[2] = round(float(r[2]), 1) r[2] = str(r[2]) return table def main(table): row_split(table) r_round(table) return table" "from typing import List def is_row_none(row: List) -> bool: return len(tuple(filter(lambda element: element is not None, row))) == 0 def is_number(string: str) -> bool: try: float(string) return True except ValueError: return False def handler_row(row: List) -> List | None: if is_row_none(row): return None result = [] for item in row: if item is None: continue if item == 'нет': result.append('0') elif item == 'да': result.append('1') elif is_number(item): result.append(str(round(float(item), 1))) elif '[at]' in item: result.append(item.replace('[at]', '@')) elif '/' in item: (part_1, part_2, part_3) = item.split('/') parts = (part_3, part_2, part_1) result.append('-'.join(parts)) return result def is_duplicate(created_table, new_row) -> bool: rows = [''.join(row) for row in created_table] ready_row = ''.join(new_row) for row in rows: if row in ready_row: return True return False def main(table) -> List: result = [] for line in table: row = handler_row(line) if row is None: continue if is_duplicate(result, row): continue result.append(row) return result" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('-') i[n] = f'{hop[2]}/{hop[1]}/{hop[0]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('да', 'Да') i[n] = i[n].replace('нет', 'Нет') return lst def format_procent(lst, n): for i in lst: j = float(i[n]) j = round(j, 2) i[n] = '{0:.2f}'.format(j) return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = j[1] + ' ' + j[0] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n].replace('(', ' (') i[n] = i[n].replace(')', ') ') return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('[at]')[0] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = splt(lst, 0, 1, sep='#') lst = format_data(lst, 0) lst = true_format(lst, 1) lst = format_procent(lst, 2) lst = transpose(lst) return lst" "import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0]] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] row1 = [] row2 = [] row3 = [] for i in data: i.pop(4) i.pop(3) i.pop(2) if i[0] == '100%': i[0] = '1.000' elif len(i[0]) == 2: i[0] = '0.0' + i[0][:-1] + '0' else: i[0] = '0.' + i[0][:-1] + '0' split = i[1].split(' ') i[1] = split[0] i[2] = re.sub('\\[at\\].*', '', i[2]) row = [] row.append(i[1]) row.append(i[0]) row.append(i[2]) new_table.append(row) new_table.sort() new_table1 = [] for i in new_table: (i[0], i[1]) = (i[1], i[0]) row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) new_table1.append(row1) new_table1.append(row2) new_table1.append(row3) return new_table1" "from operator import itemgetter def delete_duplicate_rows(table): res = [] for i in table: if i not in res: res.append(i) return res def convert(value): temp = value.replace('%', '') return str(float(temp) / 100) def transformer(i, value): if i == 0: return value.split('&')[1] if i == 1: temp = value.split('&')[1] value.replace(temp, '') name = value.split('.') return f""{name[0]}.{name[2].split('&')[0]}"" def transfrom(table): for i in range(len(table)): table[i].append(convert(table[i][0])) for i in range(len(table)): table[i].append(transformer(1, table[i][1])) for i in range(len(table)): table[i].append(transformer(0, table[i][1])) for i in range(len(table)): del table[i][1] del table[i][0] for i in range(len(table)): table[i][2] = table[i][2][:0] + '(' + table[i][2][0:] table[i][2] = table[i][2][:4] + ') ' + table[i][2][4:] table[i][2] = table[i][2][:9] + '-' + table[i][2][9:] return table def sorting(table): return sorted(table, key=itemgetter(2)) def main(table): return sorting(transfrom(delete_duplicate_rows(table)))" "def main(table): newtable = [] for i in table: number = i[0].partition(' ')[2] number3 = str(round(float(number.partition(';')[2]), 2)) if len(number3) < 4: number3 += '0' number = number.partition(';')[0] number = number[:6] + '-' + number[6:] pochta = i[1].partition('@')[2] newtable.append([number, pochta, number3]) return newtable" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('-') i[n] = f'{hop[2]}/{hop[1]}/{hop[0]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('да', 'Да') i[n] = i[n].replace('нет', 'Нет') return lst def format_procent(lst, n): for i in lst: j = float(i[n]) j = round(j, 2) i[n] = '{0:.2f}'.format(j) return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = j[0][:-1] + ' ' + j[1][:2] return lst def telephone_format(lst, n): for i in lst: i[n] = f'{i[n][1:4]}-{i[n][6:12]}{i[n][13:]}' return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('[at]')[1] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = email_format(lst, 1) lst = surname_format(lst, 0) lst = telephone_format(lst, 2) lst.sort(key=lambda x: x[2]) lst = transpose(lst) return lst" "def delete_duplicate_columns(table): new_list = [] i = 0 while table[0][i] not in new_list: new_list.append(table[0][i]) i += 1 for column in range(len(table)): del table[column][i] return table def delete_empty_columns(table): for row in table: row.remove(None) return table def delete_duplicate_rows(table): new_table = [] for row in table: if row not in new_table: new_table.append(row) return new_table def transformer(i, value): if i == 0: return f'{float(value):.3f}' if i == 1: return f'{value[2:5]} {value[5:8]}-{value[8:12]}' if i == 2: return 'Нет' if value == 'нет' else 'Да' if i == 3: return f'{value[8:]}.{value[5:7]}.{value[2:4]}' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): return transform(delete_duplicate_columns(delete_duplicate_rows(delete_empty_columns(table))))" "def main(table): tb = [] for h in table: b = [] tmp = h[0].split(';') b.append(tmp[1].split('@')[1]) b.append('(' + h[1][:3] + ') ' + h[1][3:6] + '-' + h[1][6:]) ttt = tmp[0].split() b.append(ttt[1] + ' ' + ttt[0]) tb.append(b) return tb" "def delete_duplicate_columns(table): for row in table: del row[4] return table def delete_duplicate(table): for i in range(0, len(table)): j = i + 1 while j < len(table): if table[i] == table[j]: del table[j] j += 1 return table def transform(table): for i in range(0, len(table)): a = float(table[i][0]) b = str(round(a, 2)) if len(b) < 4: b = b + '0' table[i][0] = b table[i][1] = table[i][1].replace('@', '[at]') table[i][2] = table[i][2].replace('-', '') table[i][3] = table[i][3][table[i][3].find('/') + 4:] return table def main(table): table = delete_duplicate_columns(table) for i in range(0, 2): table = delete_duplicate(table) table = transform(table) return table" "from datetime import datetime import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] row1 = [] row2 = [] row3 = [] row4 = [] for i in data: i.pop(3) i.pop(1) split = i[0].split('#') i[0] = split[0][7:13] + split[0][14:] date = datetime.strptime(split[1], '%d/%m/%Y') i2 = i[2] i[2] = re.sub('.*@', '', i[1]) i[1] = datetime.strftime(date, '%d-%m-%y') i.append(i2 + '00') row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) row4.append(i[3]) new_table.append(row1) new_table.append(row2) new_table.append(row3) new_table.append(row4) return new_table" "def main(s): a = [] filtred = [] r_list = [] f_list = [[], [], [], []] for person in s: a = list(filter(None, person)) filtred.append(a) filtred = list(filter(None, filtred)) for person in filtred: if person not in r_list: r_list.append(person) for person in r_list: number_ph = person[0] i = 0 mst = '' while number_ph[i] != '&': i += 1 i = 1 + i while i < len(number_ph): mst += number_ph[i] i += 1 replaced = mst.replace('-', '').replace(' ', '') replaced = float(replaced) * 100 replaced = round(replaced, 0) replaced = int(replaced) replaced = str(replaced) f_list[0].append(replaced + '%') numstr = person[1] email = person[1] j = 0 emal = '' while email[j] != '@': emal += email[j] j += 1 f_list[1].append(emal) tfstr = person[0] if tfstr[0] == 'В': f_list[2].append('да') else: f_list[2].append('нет') numberstr = person[3] numberstr = numberstr.replace('(', '') numberstr = numberstr.replace(')', '') numberstr = numberstr.replace('-', '') numberstr = numberstr.replace(' ', '') f_list[3].append(numberstr) f_list = list(filter(None, f_list)) return f_list" "def main(x=[[]]): i = 0 n = len(x) li = [] for i in x: if i not in li: li.append(i) x = li i = 0 n = len(x) while i < n: if not any(x[i]): x.pop(i) n -= 1 else: i += 1 for j in range(len(x)): x[j].pop(1) x[j].pop(-1) new_x = [] for q in range(len(x[0])): new_x.append([]) for w in range(len(x)): new_x[q].append(x[w][q]) for q in range(len(new_x[0])): new_x[0][q] = '(' + new_x[0][q].split()[1] + ') ' + new_x[0][q].split()[2] if new_x[1][q] == 'Нет': new_x[1][q] = 'Не выполнено' else: new_x[1][q] = 'Выполнено' new_x[2][q] = new_x[2][q].split()[2] + ' ' + new_x[2][q].split()[0] new_x[3][q] = new_x[3][q].split('@')[0] return new_x" "import re def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_row(table): k = len(table[0]) i = 0 while i < k - 1: count = i + 1 while count <= k - 1: if table[0][i] == table[0][count]: for j in range(0, len(table)): del table[j][count] count -= 1 k -= 1 count += 1 i += 1 return table def transformer(i, value): if i == 0: replaced = value.replace(' ', '').replace('-', '').replace('+', '') return replaced[4:] if i == 1: name = value.split() return f'{name[1]} {name[0]}' if i == 2: date = value.split('.') return f'{date[2]}/{date[1]}/{date[0][2:]}' if i == 3: pattern = ']([A-z]*.[A-z]*)' matches = re.findall(pattern, value) return matches[0] def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return delete_duplicate_row(transform(transpose(delete_empty_rows(table))))" "def main(table): parsed = set() result = [] for (data, phone, _, date) in table: (res, phone_p, date_p, score) = ([], [], [], []) if phone in parsed or phone is None: continue parsed.add(phone) data_s = data.split(':') score.append(str(round(int(data_s[0].strip('%')) / 100, 1))) phone_p.append(phone.replace('(', '').replace(')', '').replace(' ', '').replace('-', '')) res.append('N' if data_s[1] == '0' else 'Y') date_s = date.split('/') date_p.append(f'{date_s[2]}-{date_s[1]}-{date_s[0]}') result.append([res[0], phone_p[0], date_p[0], score[0]]) return result" "def main(table): none_row = [None, None, None, None, None] while none_row in table: table.remove(none_row) for row in table: del row[1] del row[1] del row[1] for row in table: (flag, numm) = row[0].split('|') row.insert(0, 'Да' if numm == '1' else 'Нет') namec = row[1] datec = row[2] row[1] = name(namec) row[2] = new_date(datec) def compare_tables(a1, a2): for (e1, e2) in zip(a1, a2): if e1 != e2: return False return True a = table for i in range(len(a)): j = i + 1 while j < len(a): if compare_tables(a[i], a[j]): a.pop(j) else: j += 1 return a def name(myname): i = 0 while myname[i] != ' ': i += 1 myname1 = myname[0:i] return myname1 def new_date(date): date1 = date[8:10] date2 = date[4:8] date3 = date[2:4] return date1 + date2 + date3" "from operator import itemgetter def first(s): new = [] for i in s: cur = [] for j in i: if j not in cur: cur.append(j) new.append(cur) return new def second(s): new = [] for i in s: cur = [] for j in i: if j is not None: cur.append(j) new.append(cur) new2 = [] for i in new: if len(i) != 0: new2.append(i) return new2 def third(s): new = [] for i in s: cur = [] cur.append(i[0].split(':')[0]) cur.append(i[0].split(':')[1]) cur.append(i[1]) cur[1] = cur[1].split('%')[0] new.append(cur) return new def fourth(s): for i in range(len(s)): if s[i][0] == 'true': s[i][0] = 'Выполнено' elif s[i][0] == 'false': s[i][0] = 'Не выполнено' if len(s[i][1]) >= 2: s[i][1] = '0.' + s[i][1] + '0' else: s[i][1] = '0.0' + s[i][1] + '0' s[i][2] = s[i][2][7:] return s def fifth(s): new = sorted(s, key=itemgetter(2)) new_2 = [] y_n = [] c = [] n = [] for i in new: c.append(i[1]) n.append(i[2]) y_n.append(i[0]) for i in range(len(new)): cur = [] cur.append(c[i]) cur.append(n[i]) cur.append(y_n[i]) new_2.append(cur) return new_2 def main(s): return fifth(fourth(third(second(first(s)))))" "def main(y): del_doublerow(y) del_row(y) del_kol(y) format(y) sort(y) return y def del_doublerow(y): r = len(y) i = 0 while i < r - 1: j = i + 1 while j < r: if y[i] == y[j]: y.pop(j) r -= 1 j -= 1 j += 1 i += 1 def del_row(y): i = 0 le = len(y) while i < le: check = 0 for t in range(4): if y[i][t] is None: check += 1 if check == 4: y.pop(i) i -= 1 le -= 1 i += 1 def del_kol(y): i = 0 kol = 4 le = len(y) while i < kol: check = 0 j = i + 1 while j < kol: for t in range(le): if y[t][i] == y[t][j]: check += 1 if check == le: for t in range(le): y[t].pop(j) kol -= 1 j -= 1 j += 1 i += 1 def format(y): for i in range(len(y)): y[i][0] = y[i][0][8:10] + '.' + y[i][0][5:7] + '.' + y[i][0][:4] y[i][1] = y[i][1][7:15] p = y[i][2].find('@') y[i][2] = y[i][2][:p] def sort(y): for i in range(len(y) - 1): j = i + 1 while j < len(y): if int(y[j][1][:3]) < int(y[i][1][:3]): t = y[i] y[i] = y[j] y[j] = t j += 1" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('-') i[n] = f'{hop[2]}/{hop[1]}/{hop[0]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('да', 'Y') i[n] = i[n].replace('нет', 'N') return lst def format_procent(lst, n): for i in lst: j = float(i[n]) j = round(j, 2) i[n] = '{0:.2f}'.format(j) return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = j[1] + ' ' + j[0][:2] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][3:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('[at]')[1] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = true_format(lst, 0) lst = email_format(lst, 2) lst = surname_format(lst, 3) lst = telephone_format(lst, 1) lst = transpose(lst) return lst" "def change(s): s = list(filter(None, s)) if s == []: return s new_s = list() s[0] = s[0].replace(' ', '') new_s.append(s[0][s[0].index('.') + 1:] + ' ' + s[0][0] + '.' + s[0][s[0].index('.') - 1] + '.') new_s.append(s[1].replace('[at]', '@')) if s[2] == 'Да': new_s.append('Выполнено') else: new_s.append('Не выполнено') new_s.append(str(int(float(s[3]) * 100)) + '%') return new_s def main(s): for i in range(len(s)): s[i] = change(s[i]) s = list(filter(None, s)) return s" "def main(table): result = [] for row in table: if row is None or row[1] is None or row[2] is None or (row[4] is None): continue else: cell1 = row[1].split(' ') cell2 = row[2] cell5 = row[4] name = cell1[2] + ' ' + cell1[0] yes_or_no = 'да' if cell2.split('#')[0] == 'Y' else 'нет' date_str = cell2.split('#')[1].replace('-', '.') percentage = round(float(cell5.replace('%', '')) / 100, 2) result.append([name, yes_or_no, f'{percentage:.2f}', date_str]) return result" "def main(table): tb = [] for t in table: b = [] b.append(t[0][:3] + '-' + t[0][3:5] + '-' + t[0][5:]) tmp = t[1].split('|') b.append(str(round(float(tmp[1]), 1))) b.append(tmp[0].replace('Не выполнено', 'Нет').replace('Выполнено', 'Да')) tb.append(b) result = [] k = 0 for j in range(len(tb[0])): tmp = [] for i in range(len(tb)): tmp.append(tb[i][k]) k += 1 result.append(tmp) return result" "def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0]] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] row1 = [] row2 = [] row3 = [] for i in data: if i[0] == 'true': i[0] = 'да' else: i[0] = 'нет' i[1] = str(round(float(i[1]), 2)) if len(i[1]) == 3: i[1] += '0' split = i[2].split(' ') i[2] = split[1] + ' ' + split[0][:-2] row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) new_table.append(row1) new_table.append(row2) new_table.append(row3) return new_table" "import re def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def del_duplicate_columns(table): for row in table: del row[2] return table def del_duplicate_rows(table): table = list(reversed(table)) for x in table: if table.count(x) > 1: table.remove(x) return list(reversed(table)) def del_empty_rows(table): return [row for row in table if row[0] is not None] def transformer(i, val): global bl bl = '' if val is None: return '' if i == 0: replaced = re.sub('@.*', '', val) return replaced[0:] if i == 1: return 1 if val == 'Y' else 0 if i == 2: phone = val.split('!') bl = phone[0] phone[1] = float(phone[1]) + 0.0001 return '%.3f' % phone[1] if i == 3: return f'{val[:2]} {val[2:5]} {val[5:8]}-{val[8:10]}-{val[10:12]}' def transform(table): table.append([]) global bl for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) if bl != '': table[len(table) - 1].append(bl) return table def sort(table): for i in range(len(table)): for k in range(len(table) - 1, i, -1): if table[k][0] < table[k - 1][0]: swap(table, k, k - 1) return table def swap(A, x, y): tmp = A[x] A[x] = A[y] A[y] = tmp def make_str(table): for i in range(len(table[1])): table[1][i] = str(table[1][i]) return table def main(table): return make_str(transform(transpose(del_duplicate_rows(del_duplicate_columns(sort(del_empty_rows(table)))))))" "import re def main(table): table = del_pov(table) for i in range(len(table)): table[i][0] = table[i][0].split(' ') table[i][0] = table[i][0][1] + ' ' + table[i][0][0] if table[i][1] == 'Нет': table[i][1] = 'false' else: table[i][1] = 'true' table[i][2] = table[i][2] + '0' table[i][3] = table[i][3].split(']') table[i][3] = table[i][3][1] table = sorted(table) return perevertish(table) def perevertish(table): my_list_name = [] my_list_false = [] my_list_number = [] my_list_mail = [] for i in range(len(table)): my_list_name.append(table[i][0]) my_list_false.append(table[i][1]) my_list_number.append(table[i][2]) my_list_mail.append(table[i][3]) table = [my_list_name, my_list_false, my_list_number, my_list_mail] return table def del_pov(table): for i in table: for x in i: i.reverse() if i.count(x) >= 2: i.remove(x) i.reverse() return table" "def delete_duplicate_columns(table): for i in range(len(table)): for j in range(i + 1, len(table)): if table[i][2] == table[j][2]: del table[j] return table def transform_tool(i, val): if i == 0: num = float(val) return str(round(num, 1)) if i == 1: return 'да' if val == '1' else 'нет' if i == 2: val = val[:-2] name = val.split(',') return name[0] + name[1] def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transform_tool(j, table[i][j]) return table def main(table): return transform(delete_duplicate_columns(table))" "def main(table): table = delete_empty_rows(table) newTable = [] for i in table: i = [x for x in i if x is not None] newTable.append(i) names = [] numbers = [] days = [] mails = [] for column in newTable: names.append(column[0].split(':')[0]) numbers.append(column[0].split(':')[1].replace(' ', '')) b = column[2].split('-')[1] c = column[2].split('-')[0] days.append(column[2].split('-')[2] + '-' + b + '-' + c) mails.append(column[1].replace('@', '[at]')) newTable2 = [[0] * len(names)] * 4 newNames = [] for i in names: newNames.append(i.split(' ')[1] + ' ' + i.split(' ')[0]) for i in range(len(names)): newTable2[0] = numbers newTable2[1] = mails newTable2[2] = days newTable2[3] = newNames return newTable2 def delete_empty_rows(table): return [row for row in table if row[0] is not None]" "def main(table): index = 0 seen = set() while index < len(table): if tuple(table[index]) in seen: del table[index] elif set(table[index]) == {None}: del table[index] else: seen.add(tuple(table[index])) index += 1 for (index, column) in enumerate(table[0]): if column.find('&') != -1: for line in table: column = line[index] line.pop(index) line.insert(index, column.split('&')[0]) line.insert(index + 1, column.split('&')[1]) break table.sort(key=lambda x: int(x[0][1:])) for line in table: line[0] = f'+7({line[0][2:5]}){line[0][5:8]}-{line[0][8:10]}-{line[0][10:12]}' line[1] = f'{line[1][-4:]}-{line[1][3:5]}-{line[1][:2]}' line[2] = line[2].split(' ')[1] return table" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): for row in table: del row[2] return table def transformer(i, value): if i == 0: return 'да' if value == 'Y' else 'нет' if i == 1: digit_str = value.replace('(', '') digit_str = digit_str.replace(')', '') digit = digit_str[:13] + digit_str[14:] return digit if i == 2: replaced = value.replace('-', '.') return replaced def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_duplicate_columns(delete_empty_rows(table))))" "def f(lul): n = [] for i in lul: if i not in n and i[0] is not None: n.append(i) return n def trans(matrix): trans_matrix = [[0 for j in range(len(matrix))] for i in range(len(matrix[0]))] for i in range(len(matrix)): for j in range(len(matrix[0])): trans_matrix[j][i] = matrix[i][j] return trans_matrix def main(matrix): matrix = f(matrix) trans_matrix = trans(matrix) trans_matrix = f(trans_matrix) matrix = trans(trans_matrix) for i in matrix: i[0] = i[0][3:] i[1] = i[1].replace('@', '[at]') i.append(i[1].split('|')[0]) i[1] = i[1].split('|')[1] i[1] = i[1].split('.')[1][1:] i[2] = str(int(float(i[2]) * 100)) + '%' matrix.sort(key=lambda x: x[3]) return matrix" "def main(table): a = [] for i in table: x = [] for j in i: if j is not None: x.append(j) if x: a.append(x) b = [] for i in a: x = [] for j in i: if j not in x: x.append(j) b.append(x) c = [['да' if i[0] == 'true' else 'нет', i[1].split(',')[0], '{}.{}.{}'.format(i[2][:2], i[2][3:5], i[2][-2:]), ''.join(list(filter(lambda k: k.isdigit(), i[3])))[1:]] for i in b] return c" "def main(a: list): res = [[], [], [], []] i = 0 while i < len(a): if a[i][0] is None: del a[i] else: res[0].append(str(int(a[i][0][2:])) + '%') res[1].append(a[i][1][a[i][1].find(']') + 1:]) res[2].append(a[i][2][6:]) if a[i][4] == 'Y': res[3].append('true') else: res[3].append('false') i += 1 return res" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('/') i[n] = f'{hop[2]}.{hop[1]}.{hop[0]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('false', 'нет') i[n] = i[n].replace('true', 'да') return lst def format_procent(lst, n): for i in lst: j = float(i[n]) j = round(j, 2) i[n] = '{0:.2f}'.format(j) return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = j[1] + ' ' + j[0][:2] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][3:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('@')[0] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = format_data(lst, 1) lst = true_format(lst, 2) lst = email_format(lst, 0) lst = transpose(lst) return lst" "def transpose(table): generator_range = len(table[0]) response = [[x[i] for x in table] for i in range(generator_range)] return response def delete_empty_rows(table): response = [row for row in table if row[0] is not None] return response def cut_repeated_cols(table): transposed = transpose(table) temp_table = [] [temp_table.append(x) for x in transposed if x not in temp_table] return transpose(temp_table) def transformer(i, value): if i == 0: replaced = value[0:value.find('[')] return replaced if i == 1: splitted = value.split() new_str = splitted[2] + ' ' + splitted[0][0] + '.' + splitted[1] return new_str if i == 2: return value.replace('.', '-')[2:] def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(j, table[i][j]) return table def main(table): table = cut_repeated_cols(table) table = delete_empty_rows(table) table = transform(table) return table" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_duplicate_row(table): new_table = [] for person in table: if person not in new_table: new_table.append(person) return new_table def transformer(i, value): if i == 0: surname = value.split(' ') return surname if i == 1: email = value.split('@') return email if i == 2: return 'да' if value == 'true' else 'нет' def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def set_new_name(table): for person in table: name = person[0] surname = name[:name.index('. ') + 1:-1][::-1] person[0] = surname return table def set_new_email(table): for person in table: email = person[1] new_email = email[:email.index('@'):-1][::-1] person[1] = new_email return table def set_new_bool(table): for person in table: _bool = person[2] if _bool == 'true': person[2] = 'да' elif _bool == 'false': person[2] = 'нет' return table def main(table): table = delete_duplicate_row(table) table = set_new_name(table) table = set_new_email(table) table = set_new_bool(table) table = transpose(table) return table" "def main(table): b = [] for h in table: if h.count(None) != 4 and h not in b: b.append(h) tb = [] for h in b: mass = [] for j in h: if j not in mass: mass.append(j) mass[0] = mass[0][3:6] + '-' + mass[0][6:] mass[1] = mass[1].split('@')[1] mass[2] = mass[2].replace('false', 'нет').replace('true', 'да') tb.append(mass) return tb" "def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[1] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] row1 = [] row2 = [] row3 = [] for i in data: i.pop(3) i.pop(0) i.pop(-1) split = i[0].split('#') i[0] = split[0].replace('/', '-') i[1] = i[1].replace('[at]', '@') if len(split[1]) == 2: split[1] = '0.0' + split[1][:-1] elif split[1] == '100%': split[1] = '1.00' else: split[1] = '0.' + split[1][:-1] i.append(split[1]) row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) new_table.append(row1) new_table.append(row2) new_table.append(row3) return new_table" "def main(a: list): i = 0 while i < len(a): if a.count(a[i]) > 1 or a[i][0] is None: del a[i] else: del a[i][1] a[i][0] = a[i][0][:a[i][0].find('[')] a[i][1] = 'true' if a[i][1] == '1' else 'false' a[i][2] = str(round(float(a[i][2]), 1)) i += 1 a.sort(key=lambda name: name[0]) return a" "def main(table): table = none(none(glob_none(povtorenii(table)))) for i in range(len(table)): table[i][1] = table[i][1].split('&') table[i][0] = table[i][1][0] table[i][1] = table[i][1][1] if table[i][1] == 'Выполнено': table[i][1] = 'да' else: table[i][1] = 'нет' if table[i][0] == '1.0': table[i][0] = '100%' elif table[i][0] == '0.0': table[i][0] = '0%' else: table[i][0] = table[i][0].replace('0.', '') table[i][0] = table[i][0] + '0%' table[i][2] = table[i][2].replace('-', ') ', 1) table[i][2] = '(' + table[i][2] table[i][3] = table[i][3].replace('-', '.') table[i][3] = table[i][3][-4:] + table[i][3][2:6] + table[i][3][:2] return table def glob_none(table): for elem in table: if elem == [None, None, None, None, None]: table.remove(elem) return table def none(table): for elem in table: if elem == [None]: table.remove(elem) return table def povtorenii(table): for i in table: i.reverse() for x in i: while i.count(x) != 1: i.remove(x) i.reverse() return table" "def main(_list): non = [None, None, None, None, None, None] while non in _list: _list.remove(non) for i in _list: i[0] = i[0] + '00' i[1] = i[1].replace(' ', '(', 1) i[1] = i[1].replace(' ', ')', 1) i[1] = i[1][:13] + '-' + i[1][13:] i[3] = i[3].replace('/', '.') i[5] = i[5][:i[5].find(' ')] i.remove(None) i.pop(2) _list = list(map(list, zip(*_list))) return _list" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('/') i[n] = f'{hop[2]}.{hop[1]}.{hop[0]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('да', 'Выполнено') i[n] = i[n].replace('нет', 'Не выполнено') return lst def format_procent(lst, n): for i in lst: j = float(i[n]) j = round(j, 2) i[n] = '{0:.2f}'.format(j) return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = j[0] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n][:3] + ' ' + i[n][3:6] + '-' + i[n][6:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('[at]')[1] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = splt(lst, 0, 1, sep='!') lst = true_format(lst, 2) lst = email_format(lst, 3) lst = surname_format(lst, 1) lst = telephone_format(lst, 0) return lst" "def main(x): x1 = [] for i in x: if i != [None, None, None]: x1.append(i) x = x1 for i in range(0, len(x)): x[i][0] = x[i][0][0] + '.' + x[i][0][x[i][0].find(' ') + 1:] x[i][1] = preb(x[i][2]) x[i][2] = x[i][2][x[i][2].find('!') + 1:x[i][2].find('[at]')] return x def preb(x): a = float(x[:x.find('!')]) a = a * 100 a = round(a) return str(a) + '%'" "def main(table): table = povtorenii(rem_none_two(table)) for i in range(len(table)): table[i][0] = table[i][0].replace('[at]', '@') if table[i][1] == '0': table[i][1] = 'N' else: table[i][1] = 'Y' if len(table[i][2]) == 4: table[i][2] = table[i][2].replace('0.', '') table[i][2] = table[i][2] + '%' if table[i][2][0] == '0': table[i][2] = table[i][2].replace('0', '') else: table[i][2] = '100%' return table def rem_none_two(table): for elem in table: while elem.count(None) != 0: elem.remove(None) return table def povtorenii(table): for i in table: i.reverse() for x in i: while i.count(x) != 1: i.remove(x) i.reverse() return table" "def main(x): sp = [] [sp.append(item) for item in x if item not in sp] for i in x: for k in range(len(i)): c = i.pop(0) if c not in i: i.append(c) sp = [[i[0].split()[0][:1] + '.' + i[0].split()[1] + ' ' + i[0].split()[2], i[1][3:], i[2].replace('да', 'Y').replace('нет', 'N'), i[3].replace('-', '/')] for i in sp] rez = [[sp[j][i] for j in range(len(sp))] for i in range(len(sp[0]))] return rez" "def main(x): list1 = [] for i in x: if i not in list1: list1.append(i) for a in list1: sp = a[0].split('|') a.pop(0) a.append(sp[0].replace(' ', '')) if sp[1] == 'Не выполнено': a.insert(0, 'N') elif sp[1] == 'Выполнено': a.insert(0, 'Y') list2 = [list(i) for i in zip(*list1)] list3 = [] for i in list2: if i not in list3: list3.append(i) for (i, a) in enumerate(list3[1]): list3[1][i] = '%.2f' % round(float(a), 2) return list3" "def main(data): result = [] for row in data: row = list(dict.fromkeys(row)) tmp = row[0].split('/') row[0] = f'{tmp[2]}.{tmp[1]}.{tmp[0]}' row[1] = 'true' if row[1] == 'Y' else 'false' row[2] = row[2].split('[')[0] result.append(row) result.sort() return result" "def delete_duplicate(table): i = 0 while i < len(table): if table[i][0] is None: del table[i] i -= 1 i += 1 return table def transform(table): for i in range(0, len(table)): table[i][2] = table[i][0][5:].lower() table[i][0] = table[i][0][2:4] + '%' table[i][1] = table[i][1].replace('@', '[at]') table[i][3] = table[i][3].split() table[i][3] = table[i][3][1] + ' ' + table[i][3][0] return table def main(table): table = delete_duplicate(table) table = transform(table) return table" "from typing import List, Tuple def is_row_none(row: List) -> bool: return len(tuple(filter(lambda element: element is not None, row))) == 0 def clear_extra_characters(string: str) -> str: string = string.replace('(', '') string = string.replace(')', '') string = string.replace(' ', '') string = string.replace('-', '') return string def get_email_number(string: str) -> Tuple: (number, email) = string.split('!') email = email.replace('[at]', '@') number = clear_extra_characters(number) return (email, number) def delete_duplicates(row: List) -> List: result = [] for item in row: if item not in result: result.append(item) return result def process_row(row: List) -> Tuple | None: if is_row_none(row): return None row = delete_duplicates(row) result = [] for item in row: if '!' in item: (number, email) = get_email_number(item) result.append(number) result.append(email) elif item == 'Y': result.append('Да') elif item == 'N': result.append('Нет') else: result.append(item[:-2]) return tuple(result) def main(table) -> List: result = [] for line in table: row = process_row(line) if row is None: continue result.append(row) emails = [result[i][0] for i in range(len(result))] yes_no = [result[i][2] for i in range(len(result))] number = [result[i][1] for i in range(len(result))] name = [result[i][3] for i in range(len(result))] result = [number, yes_no, emails, name] return result" "def delete_empty_columns(table): for i in range(len(table)): table[i] = [cell for cell in table[i] if cell is not None] return table def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_rows(table): unique_list = [] for row in table: if row not in unique_list: unique_list.append(row) return unique_list def delete_duplicate_columns(table): for row in table: del row[2] return table def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def transformer(j, value): if j == 0: value = value.split('!') value_first = value[0].split('-') value_first = f'{value_first[2]}-{value_first[1]}-{value_first[0]}' value_second = value[1].split(' ') value_second = f'{value_second[1]} {value_second[0]}' return [value_first, value_second] elif j == 1: value = str(round(float(value), 3)) if len(value) == 4: value = value + '0' elif len(value) == 3: value = value + '00' return value elif j == 2: return 'true' if value == 'да' else 'false' def transform(table): for i in range(len(table)): for j in range(len(table[i])): if j == 0: tmp = transformer(j, table[i][j]) table[i] = [tmp[0], table[i][1], tmp[1], table[i][2]] elif j == 1: table[i][j] = transformer(j, table[i][j]) elif j == 2: table[i][j + 1] = transformer(j, table[i][j + 1]) return table def main(table): return transpose(transform(delete_duplicate_rows(delete_duplicate_columns(delete_empty_rows(table)))))" "def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[1] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] for i in data: i.pop(2) i.pop(0) split = i[0].split('#') i[0] = str(round(float(split[1]), 1)) i1 = i[1] i[1] = split[0].replace('/', '-') i.append(i1[3:13] + i1[14:]) row = [] row.append(i[1]) row.append(i[0]) row.append(i[2]) new_table.append(row) new_table.sort() for i in new_table: (i[0], i[1]) = (i[1], i[0]) return new_table" "def main(a: list): res = [[], [], [], []] for i in range(len(a)): res[0].append(a[i][0].replace(' ', '').replace('-', '')) res[1].append(a[i][1][:a[i][1].find('[')]) res[2].append(str(int(round(float(a[i][2]), 2) * 100)) + '%') if a[i][3] == 'Выполнено': res[3].append('true') else: res[3].append('false') return res" "from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0]] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] row1 = [] row2 = [] row3 = [] for i in data: split = i[0].split(' ') i[0] = split[0] date = datetime.strptime(i[1], '%Y/%m/%d') i[1] = datetime.strftime(date, '%d-%m-%Y') i[2] = i[2].replace('@', '[at]') row = [] row.append(i[0]) row.append(i[1]) row.append(i[2]) new_table.append(row) new_table.sort() new_table1 = [] for i in new_table: row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) new_table1.append(row1) new_table1.append(row2) new_table1.append(row3) return new_table1" "def duble_delete(lst): dup_free = [] dup_free_set = set() for x in lst: if tuple(x) not in dup_free_set: dup_free.append(x) dup_free_set.add(tuple(x)) return dup_free def find_empty(lst): for i in lst: if len(set(i)) == 1 and i[0] is None: i[:] = [None] return lst def del_empty(lst): lst[:] = [x for x in lst if x != [None]] return lst def transpose(lst): result = [[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))] return result def splt(lst, n, a, sep=';'): for i in lst: s = i[n].split(sep) i[n] = s[1] i.insert(a, s[0]) return lst def format(lst, n): for i in lst: i[n] = i[n][:-2] + '-' + i[n][-2:] return lst def sor(lst): has = lst has.sort(key=lambda x: [1]) lst = has return lst def format_data(lst, n): for i in lst: hop = i[n].split('.') i[n] = f'{hop[0]}/{hop[1]}/{hop[2]}' return lst def true_format(lst, n): for i in lst: i[n] = i[n].replace('да', 'Выполнено') i[n] = i[n].replace('нет', 'Не выполнено') return lst def format_procent(lst, n): for i in lst: j = float(i[n]) j = round(j, 2) i[n] = str(int(float(j) * 100)) + '%' return lst def surname_format(lst, n): for i in lst: j = i[n].split() i[n] = j[0] return lst def telephone_format(lst, n): for i in lst: i[n] = i[n].replace('(', ' ') i[n] = i[n].replace(')', ' ') i[n] = i[n][3:13] + i[n][14:] return lst def email_format(lst, n): for i in lst: i[n] = i[n].split('[at]')[1] return lst def main(lst): lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = duble_delete(lst) lst = find_empty(lst) lst = del_empty(lst) lst = transpose(lst) lst = format_data(lst, 0) lst = format_procent(lst, 2) lst = telephone_format(lst, 1) lst.sort(key=lambda x: x[1]) return lst" "import datetime def delete_empty_rows(table): return [row for row in table if row[0] is not None] def transformer(row): s_1 = row[0] s_2 = row[1] s_1_split = s_1.split('&') check = s_1_split[1] mail = s_1_split[0].split('[at]')[1] new_date = datetime.datetime.strptime(s_2, '%Y-%m-%d').strftime('%d.%m.%Y') if check == 'Нет': return [mail, 'N', new_date] else: return [mail, 'Y', new_date] def transform(table): new_table = [] for i in table: new_table.append(transformer(i)) return new_table def main(table): return transform(delete_empty_rows(table))" "def change(s): s = list(filter(None, s)) if len(s) > 0: a = [0] * 4 else: return for i in range(len(s)): if '+' in s[i]: s[i] = s[i].replace(' ', '') s[i] = s[i].replace('-', '') a[1] = s[i][5:12] if ':' in s[i]: s[i] = s[i].replace('/', '.') s[i] = s[i][s[i].index(':') + 1:] a[2] = s[i][:6] + s[i][8:] if '@' in s[i]: a[3] = s[i][s[i].index('@') + 1:] if '%' in s[i]: s[i] = s[i].replace('%', '') a[0] = str(round(float(s[i]) / 100, 3)) a[0] += '0' * (5 - len(a[0])) return a def new_lists(s): ns1 = [] ns2 = [] ns3 = [] ns4 = [] for s_list in s: ns1.append(s_list[0]) ns2.append(s_list[1]) ns3.append(s_list[2]) ns4.append(s_list[3]) ns = [ns1, ns2, ns3, ns4] return ns def main(s): list_without_repetitions = [] for el in s: if el not in list_without_repetitions: list_without_repetitions.append(el) for i in range(len(list_without_repetitions)): list_without_repetitions[i] = change(list_without_repetitions[i]) list_without_repetitions = list(filter(None, list_without_repetitions)) return new_lists(list_without_repetitions)" "def f(lul): n = [] for i in lul: if i not in n and i[-1] is not None: n.append(i) return n def trans(matrix): trans_matrix = [[0 for j in range(len(matrix))] for i in range(len(matrix[0]))] for i in range(len(matrix)): for j in range(len(matrix[0])): trans_matrix[j][i] = matrix[i][j] return trans_matrix def main(matrix): matrix = f(matrix) trans_matrix = trans(matrix) trans_matrix = f(trans_matrix) matrix = trans(trans_matrix) for i in matrix: i[0] = i[0].split('@')[0] i[1] = i[1][5:] i.append(i[1].split('#')[0]) i[1] = i[1].split('#')[1] i[1] = str(float(i[1].strip('%')) / 100) + '0' matrix.sort(key=lambda x: x[2]) return trans(matrix)" "def main(x): sp = [] [sp.append(i) for i in x if i not in sp] for i in sp: for c in range(len(i)): a = i.pop(0) if a not in i: i.append(a) sp = [['{0:.4f}'.format(int(i[0][:-1]) / 100), i[1].replace('.', '/').replace('\t', ''), i[2].split('[')[0]] for i in sp] sp.sort(key=lambda s: s[1]) return sp" "def main(table): result = [[], [], []] for (_, boolean, data) in table: if boolean == 'Нет': result[0].append('0') else: result[0].append('1') result[1].append(data[8:10] + '/' + data[5:7] + '/' + data[2:4]) if data[-2] == '0': result[2].append(data[-1] + '%') else: result[2].append(data[-2:] + '%') return result" "def f(lul): n = [] for i in lul: if i not in n and i[-1] is not None: n.append(i) return n def trans(matrix): trans_matrix = [[0 for j in range(len(matrix))] for i in range(len(matrix[0]))] for i in range(len(matrix)): for j in range(len(matrix[0])): trans_matrix[j][i] = matrix[i][j] return trans_matrix def main(matrix): matrix = f(matrix) trans_matrix = trans(matrix) trans_matrix = f(trans_matrix) matrix = trans(trans_matrix) for i in matrix: i[0] = i[0].replace('/', '.') i.append(i[0].split(':')[0]) if i[0].split(':')[1] == '1': i[0] = 'да' elif i[0].split(':')[1] == '0': i[0] = 'нет' i[-1] = i[-1][:6] + i[-1][8:] i[1] = i[1].split('.') i[1][0] = i[1][0][:-2] i[1][1] = i[1][1][1:] i[1] = i[1][1] + ' ' + i[1][0] matrix.sort(key=lambda x: x[1]) return matrix" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_rows(table): res = [] for i in table: if i not in res: res.append(i) return res def transformer(i, value): if i == 0: return value.split('@')[1] if i == 1: a = str(round(float(value), 2)) if len(a) < 4: a = a + '0' return a if i == 2: value = value.split('!')[0] value = value.replace('(', ' ') value = value.replace(')', ' ') value = value[15::-1] value = value.replace('-', '', 1) value = value[14::-1] return value def transform(table): table.append([]) for i in range(len(table[0])): table[-1].append(transformer(2, table[0][i])) for i in range(len(table) - 1): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) (table[2], table[1]) = (table[1], table[2]) return table def main(table): return transform(transpose(delete_empty_rows(delete_duplicate_rows(table))))" "import re from datetime import datetime def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[2] is not None] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] row1 = [] row2 = [] row3 = [] for i in data: i.pop(0) i.pop(0) split = i[0].split('#') i[0] = re.sub('.*\\[at\\]', '', split[0]) i1 = i[1] i[1] = split[1][1:4] + '-' + split[1][6:] date = datetime.strptime(i1, '%d.%m.%y') i.append(datetime.strftime(date, '%y/%m/%d')) row = [] row.append(i[1]) row.append(i[0]) row.append(i[2]) new_table.append(row) new_table.sort() new_table1 = [] for i in new_table: (i[0], i[1]) = (i[1], i[0]) row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) new_table1.append(row1) new_table1.append(row2) new_table1.append(row3) return new_table1" "import re def main(table): btab = [] for row in table: if row not in btab: btab.append(row) for row in btab: row.append('') a = row[0].split('&')[0][:-2] b = row[0].split('&')[1] + '000' c = row[1].replace('@', '[at]') (row[0], row[1], row[2]) = (a, b, c) return btab" "def main(a: list): for i in range(len(a)): del a[i][0] name = a[i][1].split(' ') a[i][0] = a[i][0].replace('(', '').replace(')', '') a[i][1] = name[1][:2] + ' ' + name[0][:-1] a[i][2] = a[i][2].replace('[at]', '@') a.sort(key=lambda number: number[0]) res = [[], [], []] for i in range(3): for j in range(len(a)): res[i].append(a[j][i]) return res" "from itertools import groupby import re def main(a): a = [i for (n, i) in enumerate(a) if i not in a[:n]] a = [x for x in a if None not in x] for i in range(len(a)): a[i][0] = a[i][0].replace('N', 'нет') a[i][0] = a[i][0].replace('Y', 'да') a[i][1] = re.sub('@[a-zA-Z.-]*', '', a[i][1]) a[i][2] = re.sub('\\([0-9]*\\)\\s*', '', a[i][2]) a[i][2] = re.sub('-', '', a[i][2]) a[i][3] = str(round(float(a[i][3]), 1)) a = [[a[j][i] for j in range(len(a))] for i in range(len(a[0]))] return a" "def main(table): parsed = set() result = [] for (email, fullname, _, res, phone) in table: (email_p, surname, res_p, phone_p) = ([], [], [], []) if email in parsed or email is None: continue parsed.add(email) email_p.append(email.replace('@', '[at]')) surname.append(fullname.split()[2]) res_p.append('false' if res == 'N' else 'true') phone_s = phone.split() phone_s1 = phone_s[2].split('-') phone_p.append(f'{phone_s[1]}-{phone_s1[0]}-{phone_s1[1]}{phone_s1[2]}') result.append([email_p[0], surname[0], res_p[0], phone_p[0]]) return result" "def main(nbook): n2 = [] for i in nbook: if i not in n2 and i[1] is not None: n2.append(i) n3 = [] for i in range(0, len(n2)): stroka = n2[i][1].split('#') stroka1 = stroka[0] stroka3 = stroka[1] stroka1 = stroka1.replace('%', '') stroka1 = float(stroka1) / 100 stroka1 = str(stroka1) if len(stroka1) == 3: stroka1 += '0' stroka2 = n2[i][2].split('[at]') stroka2 = stroka2[0] stroka3 = stroka3.replace('+7 ', '') stroka3 = stroka3.split('-') stroka3 = stroka3[-3] + '-' + stroka3[-2] + stroka3[-1] n3.append([stroka1, stroka2, stroka3]) return n3" "def main(x): sp = [list(filter(lambda k: k is not None, i)) for i in x] sp = list(filter(lambda k: k != [], sp)) for i in sp: for c in range(len(i)): a = i.pop(0) if a not in i: i.append(a) sp = [[i[0].replace('Не выполнено', 'false').replace('Выполнено', 'true'), i[1][2:].replace('\t', ''), '{:.1f}'.format(float(i[2]))] for i in sp] sp.sort(key=lambda u: u[1]) rez = [[sp[j][i] for j in range(len(sp))] for i in range(len(sp[0]))] for i in range(len(rez[1])): rez[1][i] = rez[1][i][:3] + ' ' + rez[1][i][3:6] + '-' + rez[1][i][6:] return rez" "def main(x): x1 = [] for i in x: if i not in x1: x1.append(i) x = x1 for i in range(0, len(x)): x[i][0] = preb1(x[i][0]) if x[i][1][-1] == 'N': x[i][2] = 'false' else: x[i][2] = 'true' x[i][1] = preb2(x[i][1]) return x def preb1(x): x = x.split('.') x = x[2] + '/' + x[1] + '/' + x[0] return x def preb2(x): x = x[:x.find(':')] if x == '1.00': return '1.0' elif x == '0.00': return '0.0' elif x[-1] == '5': return '0.' + str(int(x[-2]) + 1) else: return str(round(float(x) * 10) / 10)" "def main(array): prearr = [] for x in array: if x not in prearr: prearr.append(x) array = prearr for i in range(0, len(prearr)): (head, sep, tail) = prearr[i][0].partition('.') prearr[i][0] = head prearr[i][0] = prearr[i][0].split() prearr[i][0].reverse() prearr[i][0][0] += '.' prearr[i][0] = ' '.join(prearr[i][0]) prearr[i].pop(1) prearr[i].pop(1) prearr[i] = prearr[i][:3] prearr[i][2] = float(prearr[i][2]) prearr[i][2] = prearr[i][2] * 100 prearr[i][2] = round(prearr[i][2]) prearr[i][2] = str(prearr[i][2]) + '%' prearr[i][1] = prearr[i][1].split('!') postarr = [] for i in range(0, len(prearr)): temp = [] for j in range(0, len(prearr[i])): if j != 1: temp.append(prearr[i][j]) else: temp.append(prearr[i][j][0]) temp.append(prearr[i][j][1]) postarr.append(temp) def rotate_90_degree_clckwise_by_zip_method(matrix): return list((list(x)[::-1] for x in zip(*matrix))) postarr = rotate_90_degree_clckwise_by_zip_method(postarr) temp = [postarr[0], postarr[2], postarr[3], postarr[1]] postarr = temp for i in range(0, len(postarr[1])): postarr[1][i] = postarr[1][i].replace('(', '') postarr[1][i] = postarr[1][i].replace(') ', '-') postarr[1][i] = postarr[1][i][:10] + postarr[1][i][11:] for i in range(0, len(postarr[3])): (head, sep, tail) = postarr[3][i].partition('@') postarr[3][i] = head for i in range(0, len(postarr)): postarr[i].reverse() return postarr" "def main(table): for row in table: (fio, mail) = row[0].split(':') row[1] = mail (fam, io) = fio.split(' ') (i, o) = io.strip('.').split('.') row[0] = i + '. ' + fam row[1] = mail.split('@')[0] row[2] = format(float(row[2]), '.3f') response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response" "def parse_result(result): (a, b, c, d) = ([], [], [], []) for arr in result: a.append(arr[0]) b.append(arr[1]) c.append(arr[2]) d.append(arr[3]) return [a, b, c, d] def main(table): parsed = set() result = [] for (phone, _, fullname, data) in table: (phone_p, fullname_p, name, res) = ([], [], [], []) if data in parsed or data is None: continue parsed.add(data) data_s = data.split('!') fullname_s = fullname.split(', ') phone_p.append(f'{phone[0:13]}{phone[14:]}') fullname_p.append(f'{fullname_s[1][0:1]}. {fullname_s[0]}') name.append(data_s[0].split('@')[0]) res.append('true' if data_s[1] == 'Выполнено' else 'false') result.append([phone_p[0], fullname_p[0], name[0], res[0]]) result = sorted(result, key=lambda x: x[2]) return parse_result(result)" "def changes(st3): if st3[0] == '1': st3[0] = 'Y' if st3[0] == '0': st3[0] = 'N' st2 = st3[1][:st3[1].index(':')] st2 = st2.replace('/', '.') st31 = st3[1][st3[1].index(':') + 1:] st31 = st3[1][st3[1].index(':') + 1:] st3[1] = st2 st31 = st31.replace('(', ' ') st31 = st31.replace(')', ' ') st31 = st31[:st31.index('-') + 3] + st31[st31.index('-') + 4:] st4 = st3[2] st3[2] = st31 st41 = st4[:st4.index(' ')] st42 = st4[st4.index(' ') + 1:] + ' ' + st41 st3.append(st42) return st3 def main(st_0): st_last = [] for i in range(len(st_0)): st_0[i] = changes(st_0[i]) st_last.append(st_0[i]) return st_last" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_rows(table): retab = [] for row in table: if row not in retab: retab.append(row) return retab def delete_duplicate_columns(table): return transpose(delete_duplicate_rows(transpose(table))) def delete_empty_columns(table): return transpose(delete_empty_rows(transpose(table))) def transformer(i, value): if i == 0: replaced = value[:2] + ' ' + value[2:5] + ' ' + value[5:8] + '-' + value[8:10] + '-' + value[10:] return replaced if i == 1: mailIndex = value.find(']') return value[mailIndex + 1:] if i == 2: return 'N' if value == 'false' else 'Y' if i == 3: return str(round(int(value[:-1]) / 100, 1)) def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_duplicate_columns(delete_duplicate_rows(delete_empty_columns(delete_empty_rows(table))))))" "def main(x): x1 = [] for i in x: if i not in x1 and i != [None, None, None]: x1.append(i) x = x1 for i in range(0, len(x)): x[i][0] = x[i][0][:x[i][0].find(',')] x[i][1] = x[i][1].replace('/', '.') x[i][2] += '00' return x" "import re def check(tb): x = len(tb) y = len(tb[0]) for i in range(x): for j in range(x): if i != j: if tb[i] == tb[j]: for k in range(y): tb[j][k] = None def per(tb): trans_m = [] for j in range(len(tb[0])): t = [] for k in range(len(tb)): t.append(tb[k][j]) trans_m.append(t) return trans_m def ref(tb): trans_m = [] for k in range(len(tb)): t = [] for j in range(len(tb[0])): if tb[k][j] is not None: t.append(tb[k][j]) if t: trans_m.append(t) return trans_m def full(tb): for i in range(len(tb)): tb[i][0] = float(tb[i][0]) tb[i][0] = round(tb[i][0], 2) tb[i][0] = tb[i][0] * 100 tb[i][0] = round(tb[i][0], 2) tb[i][0] = str(int(tb[i][0])) + '%' def main(tb): check(tb) tb = per(tb) check(tb) tb = per(tb) tb = ref(tb) full(tb) for i in range(len(tb)): tb[i][3] = re.sub(' \\w\\.', '', tb[i][3]) for i in range(len(tb)): tb[i][1] = re.sub('\\+7', '(', tb[i][1]) number = tb[i][1][0:4] + ') ' + tb[i][1][4:7] + '-' number = number + tb[i][1][7:9] + '-' + tb[i][1][9:] tb[i][1] = number for i in range(len(tb)): date = tb[i][2][8:] + tb[i][2][2:6] + tb[i][2][:2] tb[i][2] = date return tb" "def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_empty_rows(table): return [row for row in table if row[0] is not None] def delete_duplicate_columns(table): for row in table: del row[1] return table def transformer(i, value): if i == 0: return 'N' if value == 'Нет' else 'Y' if i == 1: digit_str = value[value.find(']') + 1:] return f'{digit_str}' if i == 2: name = value.split() return f'{name[0]}' if i == 3: replaced = value.replace('(', '').replace(')', '') n = replaced.rfind('-') replaced = replaced[:n] + replaced[n + 1:] return replaced def transform(table): for i in range(len(table)): for j in range(len(table[i])): table[i][j] = transformer(i, table[i][j]) return table def main(table): return transform(transpose(delete_duplicate_columns(delete_empty_rows(table))))" "import re def main(table): table = rem_none_two(glob_none(povtorenii(table))) table = sup_prov(table) for i in range(len(table)): table[i][0] = table[i][0] + '00' table[i][1] = table[i][1].split(' ') table[i][1] = table[i][1][2] table[i][2] = table[i][2].replace('[at]', '@') if table[i][3] == 'Y': table[i][3] = 'Да' else: table[i][3] = 'Нет' return new_tab(table) def new_tab(table): my_list_pers = [] my_list_data = [] my_list_name = [] my_list_ = [] for i in range(len(table)): my_list_pers.append(table[i][0]) my_list_data.append(table[i][1]) my_list_name.append(table[i][2]) my_list_.append(table[i][3]) table = [my_list_pers, my_list_data, my_list_name, my_list_] return table def sup_prov(table): for elem in table: for micro in elem: while elem.count(micro) > 1: elem.remove(micro) return table def glob_none(table): for elem in table: if elem == [None, None, None, None, None, None]: table.remove(elem) return table def rem_none_two(table): for elem in table: while elem.count(None) != 0: elem.remove(None) return table def povtorenii(table): table.reverse() for i in table: while table.count(i) != 1: table.remove(i) table.reverse() return table" "def main(s): q = 0 w = 0 e = 0 p = 0 a = [] filtred = [] r_list = [] f_list = [[], [], [], []] for person in s: a = list(filter(None, person)) filtred.append(a) filtred = list(filter(None, filtred)) for person in filtred: if person not in r_list: r_list.append(person) for person in r_list: data_ph = person[0] i = 0 f_list[q].append(data_ph[8:10] + '/' + data_ph[3:5] + '/' + data_ph[0:2]) q = 1 + q numstr = person[1] while numstr[i] != ';': i = i + 1 if numstr[i + 1] == 'f': f_list[w].append('Не выполнено') else: f_list[w].append('Выполнено') w = 1 + w email = person[2] i = 0 eml = '' while email[i] != '[': eml += email[i] i = i + 1 f_list[p].append(eml) e = e + 1 numstr = person[1] i = 0 qwerty = '' while numstr[i] != ';': qwerty += numstr[i] i = i + 1 phone = qwerty.replace(' ', '').replace('-', '') f_list[p].append(phone) p = p + 1 f_list = list(filter(None, f_list)) return f_list" "def main(table): b = [] tosort = {} for i in table: if i.count(None) != 3: tmp = i[0].split('#') tmp[1] = tmp[1].replace('@', '[at]') tmp.append(i[1]) tmp.append(i[2]) phone_edit = tmp[0][3:34] f_e = '(' + phone_edit[0:3] + ')' phone_edit = f_e + phone_edit[3:].replace('-', ' ', 2) f_n = phone_edit[0:9] phone_edit = f_n + '-' + phone_edit[10:].replace(' ', '') tmp[0] = phone_edit edit_data = tmp[2][8:] + tmp[2][4:7] + '-' + tmp[2][2:4] edit_data = edit_data.replace('/', '-') tmp[2] = edit_data boofer = tmp[1] tmp[1] = edit_data tmp[2] = boofer edit_name = tmp[3] if edit_name == 'Додавиди, А.Е.': edit_name = 'А. Додавиди' else: edit_name = edit_name.replace(',', '') edit_name = edit_name.split() final_name = edit_name[1][0:2] + ' ' + edit_name[0] edit_name = final_name tmp[3] = edit_name b.append(tmp) tosort[tmp[0]] = tmp tosort = dict(sorted(tosort.items())) tb = list(tosort.values()) return tb" "def main(table): result = [[], [], []] for row in table: if row[0] == 'Не выполнено': result[0].append('false') else: result[0].append('true') row[1] = row[1][:13] + row[1][13 + 1:] result[1].append(row[1].replace('(', ' ').replace(')', ' ')) ab = float(row[2].split('%')[0]) / 100 result[2].append(str(round(ab, 1))) return result" "def del_row_dup(table): unique_table = [] for row in table: if row not in unique_table: unique_table.append(row) return unique_table def del_empty_rows(table): clear_table = [] for row in table: if row[0] is not None: clear_table.append(row) return clear_table def transpose(table): transposed_table = [] for i in range(0, len(table[0])): row = [] for j in range(0, len(table)): row.append(table[j][i]) transposed_table.append(row) return transposed_table def split_second_line(table): required_table = [] required_table.append(table[0]) line_date = [] line_fio = [] for item in table[1]: splitted_item = item.split(';') line_date.append(splitted_item[0]) line_fio.append(splitted_item[1]) required_table.append(line_date) required_table.append(line_fio) required_table.append(table[2]) return required_table def main(table): COMPLETED = 'Выполнено' NOT_COMPLETED = 'Не выполнено' clear_table = del_empty_rows(table) transp_table = transpose(clear_table) cleaned_column_transposed_table = del_row_dup(transp_table) cleaned_column_table = transpose(cleaned_column_transposed_table) cleaned_table = del_row_dup(cleaned_column_table) required_table = transpose(cleaned_table) for i in range(len(required_table[0])): t = '{0:.1f}'.format(round(float(required_table[0][i]), 1)) required_table[0][i] = t required_table = split_second_line(required_table) for i in range(len(required_table[1])): cleared_item = required_table[1][i].replace('.', '-') required_table[1][i] = cleared_item[:6] + cleared_item[8:] for i in range(len(required_table[2])): splitted_item = required_table[2][i].split() required_table[2][i] = splitted_item[1][:splitted_item[1].find('.') + 1] + ' ' + splitted_item[0] for i in range(len(required_table[3])): if required_table[3][i] == COMPLETED: required_table[3][i] = 'да' elif required_table[3][i] == NOT_COMPLETED: required_table[3][i] = 'нет' return required_table" "def main(x): for i in range(0, len(x)): x1 = [] for j in range(0, len(x[i])): if x[i][j] not in x1 and x[i][j] is not None: x1.append(x[i][j]) x[i] = x1 x[i][0] = preb2(x[i][0]) if x[i][1] == 'Y': x[i][1] = '1' else: x[i][1] = '0' x[i][2] = x[i][2][7:].replace('-', '') x[i][3] = preb(x[i][3]) return x def preb(x): x = x.split('/') return x[2] + '-' + x[1] + '-' + x[0] def preb2(x): return x[x.find(' ') + 1:] + ' ' + x[:x.find('.') + 1]" "def main(t): t = list(filter(lambda x: len(x) > 0, list(map(lambda l: list(filter(lambda x: x is not None, l)), t)))) ts = set() t1 = [] for i in t: if not tuple(i) in ts: ts.add(tuple(i)) t1.append(i) t = t1 t = list(map(lambda x: [x[0].split(' ')[1], x[1].replace('-', '.'), format(float(x[2]), '.4f'), 'да' if x[3] == 'Выполнено' else 'нет'], t)) t = map(list, zip(*t)) return list(t)" "import re def main(*args): unzip = [*args] data = [x for i in unzip for x in i] tpls = [tuple(x) for x in data if x[0]] dct = dict.fromkeys(tpls) data = [list(x) for x in dct] new_table = [] row1 = [] row2 = [] row3 = [] row4 = [] for i in data: split = i[0].split('!') i[0] = re.sub('.*\\[at\\]', '', split[0]) i1 = i[1] if split[1] == 'Не выполнено': i[1] = 'Нет' else: i[1] = 'Да' i2 = i[2] i[2] = i1[2:7] + ' ' + i1[7:] split = i2.split(' ') i.append(split[2] + ', ' + split[0][0] + '.' + split[1]) row = [] row.append(i[3]) row.append(i[1]) row.append(i[2]) row.append(i[0]) new_table.append(row) new_table.sort() new_table1 = [] for i in new_table: (i[0], i[3]) = (i[3], i[0]) row1.append(i[0]) row2.append(i[1]) row3.append(i[2]) row4.append(i[3]) new_table1.append(row1) new_table1.append(row2) new_table1.append(row3) new_table1.append(row4) return new_table1" "def delete_copies(table): temp = [] for a in table: if a not in temp: temp.append(a) return temp def delete_nones(table): return [x for x in table if None not in x] def split_by(table): for string in table: for col in string: if '|' in col: string.insert(3, col[6:col.index('|')].replace('-', '')) string.insert(0, change_date(col)) string.pop(string.index(col)) elif '[' in col: string.pop(string.index(col)) string.insert(1, col.replace('[at]', '@')) elif ' ' in col: string.pop(string.index(col)) string.insert(2, col[:col.index(' ')]) return table def change_date(s): s = s[s.index('|') + 1:] s = s[6:8] + '-' + s[3:5] + '-' + s[0:2] return s def main(table): return sorted(split_by(delete_copies(delete_nones(table))), key=lambda x: x[2])" "from collections import OrderedDict from itertools import groupby def transpose(table): response = [] for i in range(len(table[0])): response.append([]) for j in range(len(table)): response[i].append(table[j][i]) return response def delete_duplicate_columns(table): return transpose(delete_duplicate_rows(transpose(table))) def delete_empty_columns(table): return [row for row in table if row[0] is not None] def delete_duplicate_rows(table): seen = [] new_table = [] for row in table: if row[0] in seen: continue seen.append(row[0]) new_table.append(row) return new_table def delete_empty_rows(table): return transpose(delete_empty_columns(transpose(table))) def transformer_1(table): for i in range(len(table)): table[i][0] = table[i][0].replace('\n', ' ') (first_name, last_name) = table[i][0].split() table[i][0] = last_name.strip() + ' ' + first_name.strip() return table def transformer_2(table): for i in range(len(table)): str_1 = table[i][1][slice(0, 2)] str_2 = table[i][1][slice(2, 5)] str_3 = table[i][1][slice(5, 8)] str_4 = table[i][1][slice(8, 10)] str_5 = table[i][1][slice(10, 12)] table[i][1] = str_1 + ' (' + str_2 table[i][1] = table[i][1] + ') ' + str_3 + '-' table[i][1] = table[i][1] + str_4 + '-' + str_5 return table def transformer_3(table): for i in range(len(table)): for j in range(len(table[i][2])): if table[i][2][j] == '/': table[i][2] = table[i][2].replace('/', '-') return table def transformer(table): return transformer_3(transformer_2(transformer_1(table))) def row_pos(table): for i in range(len(table) - 1): for j in range(i + 1, len(table)): if table[i][1][4] > table[j][1][4]: t = table[i] table[i] = table[j] table[j] = t for i in range(len(table) - 1): for j in range(i + 1, len(table)): if table[i][1][4] == table[j][1][4]: if table[i][1][5] > table[j][1][5]: t = table[i] table[i] = table[j] table[j] = t return table def main(table): return row_pos(transformer(delete_empty_rows(delete_duplicate_columns(delete_empty_columns(delete_duplicate_rows(table))))))"