I am trying to split a txt file with multiple lines into separate variables. The text is an output of volume information with names, data sizes, etc. and I wan to split each dataset into a specific variable but can't seem to get it
Example is trying to split this data set into a variable for each item
/vol0 abcd4 Object RAID6+ 228.33 GB -- 400.00 GB Online
/vole1 abcd1 Object RAID6+ 44.19 TB 45.00 TB 45.00 TB Online
/vole2 abcd4 Object RAID6+ 11.27 TB 11.00 TB 12.00 TB Online
/vol3 abcd4 Object RAID6+ 9.50 TB -- 10.00 TB Online
/vol4 abcd1 Object RAID6+ 18.39 TB -- 19.10 TB Online
This is the command I've run, but I keep getting an error about "not enough values to unpack
".
inputfile = "dataset_input.txt"
with open(inputfile, "r") as input:
for row in input:
vol, bs, obj, raid, used, uunit, quota, qunit, q2, q2unit, status = row.split()
I can split the file by space just by doing the below text and it works. Just can't seem to get it into separate variables so I can manipulate the datasets
for row in input: #running through each row in the file
output_text = row.split() #split the row based on the default white-space delimiter
print(output_text)
I'm very new to python, so not sure if this is even possible, or how complicated it is