I would like to load a csv file as a numpy array. Each row contains string fields with spaces. I tried with both loadtxt() and genfromtxt() methods available in numpy. By default both methods consider space as a delimiter and separates each word in the string as a separate column. Is there anyway to load this sort of data using loadtxt() or genfromtxt() or will I have to write my own code for it?
Sample row from my file:
826##25733##Emanuele Buratti## ##Mammalian cell expression
Here ## is the delimiter and space denotes missing values.
np.genfromtxt(trainFile, dtype = str, delimiter = '##', comments = '//', missing_values = ' ')
loadtxt follows similar syntax. – viper May 21 '13 at 4:05