No Description

organizar.py 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import os, sys
  2. import json
  3. path1 = "C:/Users/diego/Documents/companion_app/primer_sem"
  4. path2 = "C:/Users/diego/Documents/companion_app/segundo_sem"
  5. path3 = "C:/Users/diego/Documents/companion_app/Miupi Parser"
  6. dirs1 = os.listdir(path1)
  7. dirs2 = os.listdir(path2)
  8. dirs3 = os.listdir(path3)
  9. def orderFiles1(files1):
  10. i = 1
  11. for file in dirs1:
  12. if file.endswith('.json'):
  13. files1.append({'file': file, 'num': i})
  14. i += 1
  15. return files1
  16. def orderFiles2(files2):
  17. i = 1
  18. for file in dirs2:
  19. if file.endswith('.json'):
  20. files2.append({'file': file, 'num': i})
  21. i += 1
  22. return files2
  23. def orderFiles3(files1, files2, files3):
  24. for i in range(len(files1)):
  25. files3.append({'file': files1[i]['file'], 'num': files1[i]['num']})
  26. files3.append({'file': files2[i]['file'], 'num': files1[i]['num']})
  27. return files3
  28. def orderFilesProxSemestre(files):
  29. """
  30. Organizing all the files from Miupi Parser to a single array. The array will contain each directory of each file
  31. """
  32. i = 1
  33. for file in dirs3:
  34. if file.endswith('.json'):
  35. files.append({'file': file, 'num': i})
  36. i += 1 # parse.py esta entre medio
  37. return files
  38. files1 = orderFiles1([])
  39. files2 = orderFiles2([])
  40. files3 = []
  41. files3 = orderFiles3(files1, files2, files3)
  42. proxSemFiles = orderFilesProxSemestre([])