Using genfromtxt to import csv data with missing values ​​in numpy

I have a csv file that looks something like this (the actual file has a lot more columns and rows):

1,2,3,4,5
6,7,8,9,10
11,12,13,14,15
16

Let's say the file name is info.csv If I try to import this using

data = numpy.genfromtxt('info.csv', delimiter = ',')

then I get the following error:

ValueError: Some errors were detected ! Line #4 (got 1 columns instead of 5)

If i use

data = numpy.genfromtxt('info.csv', delimiter = ',', skip_footer = 1) 

both lines with data 16and with data are 11, 12, 13, 14, 15skipped. I do not understand why the line with is 11, 12, 13, 14, 15skipped. I would appreciate any help on how I can use the genfromtxtfirst three lines in the above file to import accordingly .

thank

+5
source share
1 answer

All Articles