i want to run my py code multiple times, with different inputs & all at the same time with one exe.
My informations are all saved in one csv, & my problem is i dont know how i can run my script multiple times at the same time, with different inputs. My code is still the same but i need some other inputs in it from the csv.
So as example: my csv has 20 rows so my code will run 20 times, but in every row is another argument what i need.
if anyone know how this works, would be glad.
Thanks
do you means: there's a 20 rows in a csv file, and you wanna choose one of the line in the file randomly?
import pandas as pd
data = pd.read_csv("your_csv.csv")
import random
x = random.randint(0, 20)
print(data[:, x])
if you want to run the file 20 times, and handle a line each time, you need to save the current run step in some file:
step = 0
with open('step.txt', mode='r+', encoding='utf-8') as f:
line = f.read()
if line is not None:
step = int(line)
if step >= 20 or step < 0:
step = 0
data = data[:, step]
# your logic to handle current line
step = step + 1
f.write(str(step))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.