Jun-30-2018, 07:18 PM
Hello,
I have a CSV file that looks something like this:
strings
strings
data (float)
data (float)
data (float)
strings
strings
strings
data (float)
data (float)
...
etc
The file contains many rows and two columns and I would like to load e.g. all the columns in row 1 to 5 in a numpy array. Additionally, I would like to store e.g. row 6-144 in another array (all those rows are data) etc. Is there a way to do this? I tried things like np.loadtxt, csv.reder and pandas.read_csv but I must be missing something. I would prefer to do it without using a loop due to the time consumption when the files get very large.
If someone use MATLAB and know the python way to do this, here's a hint:
MATRIX = dlmread('FILE.csv',',',[5 0 144 1]);
This stores row 5 to 144 and colum 0 to 1 if a matlab code.
Thanks in advance!
I have a CSV file that looks something like this:
strings
strings
data (float)
data (float)
data (float)
strings
strings
strings
data (float)
data (float)
...
etc
The file contains many rows and two columns and I would like to load e.g. all the columns in row 1 to 5 in a numpy array. Additionally, I would like to store e.g. row 6-144 in another array (all those rows are data) etc. Is there a way to do this? I tried things like np.loadtxt, csv.reder and pandas.read_csv but I must be missing something. I would prefer to do it without using a loop due to the time consumption when the files get very large.
If someone use MATLAB and know the python way to do this, here's a hint:
MATRIX = dlmread('FILE.csv',',',[5 0 144 1]);
This stores row 5 to 144 and colum 0 to 1 if a matlab code.
Thanks in advance!