I think I know of a way to do this, but I'd like to see if there is a bettery way. So here is the the file for just one part I'm trying to read from (and then write back to)
['Part assembly name', <name of assembled part>]
['Parts', <part1>, <part2>, <part3>]
['Quantities', 5, 8, 2]
['Part category, <category type 1>, <category type 2>]
If I save each line to an array, I can write each one with json
myfile = file('partsList.txt', 'w')
for x in (names, ingedients, volumes, category):
json.dump(x, myfile)
myfile.write('\n')
I should able to read each line back with:
with open(fname) as f:
names.append(f.readlines())
parts.append(f.readlines())
quanties.append(f.readlines())
categories.append(f.readlines())
So after reading all of my different part assemblies from my file I should have four arrays (or maybe 1 2 dimensional array)
names = [<name of assembly 1>, <name of assembly 2>, <name of assembly 3>]
parts = [<array of parts for 1>, <array of parts for 2>, <array of parts for 3>]
quantites = [<array of quantites for 1>, <array of quantites for 2>, <array of quantites for 3>]
categories= [<array of categoriesfor 1>, <array of categoriesfor 2>, <array of categoriesfor 3>]
is there a better/easier way to do this? I don't want to try to reinvent the wheel. Thanks!