0

I am using python to read data from .csv file. The .csv file has saved data in one cell(col3 data) separated by commas. I want to put these data in numpy array. The dataset looks like bellow

col1     col2     col3
1        1        1,2,3,4,...
2        2        1,2,3,4,...
3        3        1,2,3,4,...

dataset.csv

Can someone help me to read .csv file col3 data and save into numpy array? The data in col3 is really big, one cell has 1080 data. I tried to save these data in separated columns using pandas but since .csv file only has 255 columns, it doesn't save all the data.

Thank you

piRSquared
  • 285,575
  • 57
  • 475
  • 624
  • That `png` image isn't a `csv` text file. What is the delimiter for the 3 'main' columns? tab? white space? It's hard to mix that kind of column with the `,` separation for `ranges`. – hpaulj Sep 01 '17 at 05:42
  • Read it in as is (separated by whitespace), then split col3 on the comma, as per the duplicate question. –  Sep 01 '17 at 05:47
  • It is just the format of .csv file. In column3 data(ranges) saved into cell separated by using commas. There is 1080 data in one cell. What I want to do is, add those column3(ranges) data into numpy array. – Viduranga Munasinghe Sep 01 '17 at 05:47

1 Answers1

1
df.col3.str.split(',', expand=True).apply(pd.to_numeric, errors='coerce').values
piRSquared
  • 285,575
  • 57
  • 475
  • 624