No Description

organizar.py 1.5KB

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