Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def insert(source_str, insert_str, pos):
- return source_str[:pos] + insert_str + source_str[pos:]
- def main(table):
- new_table = list()
- for el in table:
- temp_row = list(filter(None, dict.fromkeys(el)))
- if temp_row:
- temp_row[0] = temp_row[0].split(';')
- temp_row[0][0] = temp_row[0][0][:2] + temp_row[0][0][4:]
- temp_row[0][1] = insert(insert(temp_row[0][1][3:], '-', 3), '-', 6)
- temp_row[0:1] = temp_row[0]
- temp_row[2] = str(round(float(temp_row[2]) * 100)) + '%'
- temp_row[3] = '/'.join(temp_row[3].split('-')[::-1])
- temp_row.insert(3, temp_row.pop(1))
- temp_row.insert(2, temp_row.pop(1))
- new_table.append(tuple(temp_row))
- new_table = list(filter(None, dict.fromkeys(new_table)))
- trans_table = [[new_table[j][i] for j in range(
- len(new_table))] for i in range(len(new_table[0]))]
- return trans_table[::-1]
- print(main([[None, None, None, None], ['И.Ш. Фотуфяк;6739989068', '0.6132', '26-08-2001', '26-08-2001'],
- ['И.Д. Сешянц;6165320334', '0.4317', '28-03-2002', '28-03-2002'],
- ['Р.Ш. Лебский;6884972383', '0.7691', '21-07-2003', '21-07-2003'],
- ['Р.Ш. Лебский;6884972383', '0.7691', '21-07-2003', '21-07-2003']]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement