I have created a function where the user is prompted to enter the quantity and names of the csv files that he wants to open and read.
After checking that the correct filenames have been read and appended to a list I want the function to open each of those files and add each column of the file to a new variable.
files = ['file_a','file_b','file_c','file_d']
These are the variables that will store the feature values of each file.
data1 = []
data2 = []
data3 = []
data4 = []
data5 = []
Then I appended the separate features in each of these variables
for row in file:
rows = row.split(',')
try:
data1.append((rows[0]))
data2.append(float(rows[1]))
data3.append(float(rows[2]))
data4.append(float(rows[3]))
data5.append(float(rows[4]))
except IndexError:
continue
Before that loop closes though I want a new variable created that will hold the data1 to data5 of each csv file separately and can be returned so I can use it further in my script. Is there a way to do that?