Reading CSV file using numpy in python 2.7 -
i have csv file of following format:
x1 y1 z1 x2 y2 z2 cost 1 2 3 4 4 5 60
...etc in excel. however, in wordpad, represented so:
x1,y1,z1,x2,y2,z2,cost 1,2,3,4,4,5,60
basically, delimiter ','. trying read csv file using numpy, using genfromtxt. here code:
import numpy np import csv stringio import stringio open ('1250_12.csv','rb') csvfile: data = np.genfromtxt(csvfile, dtype = none, delimiter = ',') print data
although there no errors, program prints out
[['x1' 'y1' 'z1' ..., 'y2' 'z2' 'cost'] ['5720.44' '3070.94' '2642.19' ..., '3061.01' '2576.29' '102.12'] ['5720.44' '3070.94' '2642.19' ..., '3023.6' '2597.81' '110.4'] ..., ['5748.56' '3102' '2631.75' ..., '3215.74' '2657.41' '148.58'] ['5748.56' '3102' '2631.75' ..., '3156.07' '2598.65' '110.08'] ['5748.56' '3102' '2631.75' ..., '3178.16' '2627.18' '132.85']]
i know numbers different lets pretend same. basically, program prints out first 3 , last 3 rows of csv file. may due csv file being large, i'm not sure. problem 'x1' , data vanished. question is, error? did vanish because file big? new numpy
try putting:
np.set_printoptions(threshold='nan')
before print data
Comments
Post a Comment