Jan-08-2019, 07:01 PM
(This post was last modified: Jan-08-2019, 07:02 PM by SchroedingersLion.)
Good evening,
can someone help me with the syntax in saving the rows of a csv files with M rows and N columns into a list?
I do not want the last column, but all of the M rows.
Thus, the list should look like an M x (N-1) matrix.
The last column should be saved to a Y list.
In my case, N=82 and M=26000.
can someone help me with the syntax in saving the rows of a csv files with M rows and N columns into a list?
I do not want the last column, but all of the M rows.
Thus, the list should look like an M x (N-1) matrix.
The last column should be saved to a Y list.
In my case, N=82 and M=26000.
import csv import os #give path to training / test data files data_path='XXX' #READ IN DATA x_training = [] y_training = [] print(os.getcwd()) with open(data_path) as csv_file: data = csv.reader(csv_file, delimiter=",") for row in data: for k in range(81): # now what? How do I write it :( y_training.append(float(row[-1]))Regards!