I currently have the following file load.py which contains:
readText1 = "test1"
name1 = "test1"
readText1 = "test2"
name1 = "test2"
Please note that the number will change frequently. Sometimes there might be 2, sometimes 20 etc.
I need to do something with this data and then save it individually.
In my file I import load like so:
from do.load import *
#where do is a directory
I then create a variable to know how many items are in the file (which I know)
values = range(2)
I then attempt to loop and use each "variable by name" like so:
for x in values:
x = x + 1
textData = readText + x
nameSave = name + x
Notice I try to create a textData variable with the readText but this won't work since readText isn't actually a variable. It errors. This was my attempt but it's obviously not going to work. What I need to do is loop over each item in that file and then use it's individual variable data. How can I accomplish that?
load.pywill accomplish?