datasets_all.py 1.1 KB

12345678910111213141516171819202122232425
  1. import os
  2. import pandas as pd
  3. from concurrent.futures import ThreadPoolExecutor
  4. # Function to execute the ParsingData.py script
  5. def execute_parsing_data(input_value, output_value, type_value):
  6. command = f"python ParsingData.py -i {input_value} -o {output_value} -f {type_value}"
  7. os.system(command)
  8. # Load the dataset from the XLSX file using openpyxl engine
  9. dataset = pd.read_excel(r"C:\Users\aswen\Desktop\Code\2023_Kalantari_AIDAqc\outputs\files_4figs\datasetrun.xlsx", engine="openpyxl")
  10. # Determine the number of available processors
  11. num_processors = os.cpu_count() or 1 # Use at least 1 if os.cpu_count() returns None
  12. # Create a ThreadPoolExecutor with the determined number of threads
  13. with ThreadPoolExecutor(max_workers=num_processors) as executor:
  14. # Iterate through the rows of the dataset and submit tasks to the executor
  15. for index, row in dataset.iterrows():
  16. input_value = row["input"]
  17. output_value = row["output"]
  18. type_value = row["type"]
  19. # Submit the task to the ThreadPoolExecutor
  20. executor.submit(execute_parsing_data, input_value, output_value, type_value)