Нема описа

organizar.py 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import os, sys
  2. import json
  3. path1 = "C:/Users/diego/Documents/companion_app_gh/primer_sem"
  4. path2 = "C:/Users/diego/Documents/companion_app_gh/segundo_sem"
  5. dirs1 = os.listdir(path1)
  6. dirs2 = os.listdir(path2)
  7. def orderFiles1(files1):
  8. i = 1
  9. for file in dirs1:
  10. if file.endswith('.json'):
  11. files1.append({'file': file, 'num': i})
  12. i += 1
  13. return files1
  14. def orderFiles2(files2):
  15. i = 1
  16. for file in dirs2:
  17. if file.endswith('.json'):
  18. files2.append({'file': file, 'num': i})
  19. i += 1
  20. return files2
  21. def orderFiles3(files1, files2, files3):
  22. for i in range(len(files1)):
  23. files3.append({'file': files1[i]['file'], 'num': files1[i]['num']})
  24. files3.append({'file': files2[i]['file'], 'num': files1[i]['num']})
  25. return files3
  26. files1 = orderFiles1([])
  27. files2 = orderFiles2([])
  28. files3 = []
  29. files3 = orderFiles3(files1, files2, files3)
  30. # for file in files3:
  31. # check = file['file'].split('.')
  32. # path = "C:/Users/diego/Documents/companion_app/segundo_sem" if check[0][-1] == '2' else "C:/Users/diego/Documents/companion_app/primer_sem"
  33. # with open(path + '/' + file['file']) as f:
  34. # data = json.load(f)
  35. # fac_id = file['num']
  36. # for key in data:
  37. # if key != 'Horario ':
  38. # code = key
  39. # name = data[key][0]
  40. # creds = data[key][1]
  41. # print(code, name, creds, fac_id)