Advertisement
selebry

9

May 14th, 2023
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. def insert(source_str, insert_str, pos):
  2. return source_str[:pos] + insert_str + source_str[pos:]
  3.  
  4.  
  5. def main(table):
  6. new_table = list()
  7. for el in table:
  8. temp_row = list(filter(None, dict.fromkeys(el)))
  9. if temp_row:
  10. temp_row[0] = temp_row[0].split(';')
  11. temp_row[0][0] = temp_row[0][0][:2] + temp_row[0][0][4:]
  12. temp_row[0][1] = insert(insert(temp_row[0][1][3:], '-', 3), '-', 6)
  13. temp_row[0:1] = temp_row[0]
  14. temp_row[2] = str(round(float(temp_row[2]) * 100)) + '%'
  15. temp_row[3] = '/'.join(temp_row[3].split('-')[::-1])
  16. temp_row.insert(3, temp_row.pop(1))
  17. temp_row.insert(2, temp_row.pop(1))
  18. new_table.append(tuple(temp_row))
  19. new_table = list(filter(None, dict.fromkeys(new_table)))
  20. trans_table = [[new_table[j][i] for j in range(
  21. len(new_table))] for i in range(len(new_table[0]))]
  22. return trans_table[::-1]
  23.  
  24.  
  25. print(main([[None, None, None, None], ['И.Ш. Фотуфяк;6739989068', '0.6132', '26-08-2001', '26-08-2001'],
  26. ['И.Д. Сешянц;6165320334', '0.4317', '28-03-2002', '28-03-2002'],
  27. ['Р.Ш. Лебский;6884972383', '0.7691', '21-07-2003', '21-07-2003'],
  28. ['Р.Ш. Лебский;6884972383', '0.7691', '21-07-2003', '21-07-2003']]))
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement