trytryhard

junction_new

Oct 23rd, 2022 (edited)
603
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.23 KB | None | 0 0
  1.  
  2. import time
  3. import os
  4.  
  5. # files/folders vvvv
  6. print("(full)path to list of files/folders:")
  7. path_to_f=str(input())
  8. f=open(path_to_f, 'r',encoding='utf-8-sig')
  9. list_of_f = f.readlines()
  10. f.close()
  11.  
  12. if len(list_of_f) == 0:
  13.     print("empty list")
  14.     exit()
  15.  
  16. #prepare pathes
  17. for i in range(len(list_of_f)):
  18.     list_of_f[i] = list_of_f[i].replace('\n','')
  19.  
  20. list_of_f = list(filter(str.strip, list_of_f))
  21.  
  22. for i in range(len(list_of_f)):
  23.     if list_of_f[i].__contains__('.') == False:
  24.         list_of_f[i]+='/*'
  25.  
  26. # vars vvvv
  27. print("(full)path to list of variables:")
  28. path_to_var=str(input())
  29. v=open(path_to_var,'r',encoding='utf-8-sig')
  30. list_of_v = v.readlines()
  31. v.close()
  32.  
  33. #prepare vars
  34. for i in range(len(list_of_v)):
  35.     list_of_v[i] = list_of_v[i].replace('\n','')
  36.  
  37. # junction
  38. result_name = "result_"+str(time.time())+".csv"
  39. result_file = open(result_name,"w")
  40. result_file.write("STRING-VALUE,RULE-NAME,COMMENT\n")
  41.  
  42. for i in range(len(list_of_v)):
  43.     for j in range(len(list_of_f)):
  44.         result_line = list_of_f[j].replace('*',list_of_v[i],1)
  45.         result_file.write(result_line+',,\n')
  46.  
  47. result_file.close()
  48. print("result of junction: "+result_name)
  49. print("\npath to restults:"+os.getcwd()+result_name)
Tags: py3
Advertisement
Add Comment
Please, Sign In to add comment