
Untitled
By: a guest on
Jun 9th, 2012 | syntax:
None | size: 0.62 KB | hits: 35 | expires: Never
How can I combine two fields into one when importing from a file into numpy array?
#RIC,Date[G],Time[G],GMT Offset,Type,Open,High,Low,Last,Volume
ADH0,20100103,22:18:00.000,-6,Intraday 1Min,0.8915,0.8915,0.8915,0.8915,0
ADH0,20100103,22:22:00.000,-6,Intraday 1Min,0.89,0.89,0.89,0.89,0
a = np.genfromtxt(f, names=True, delimiter=',', dtype="|S8,i4,|S12,f8", usecols=(0, 1, 2, 8), autostrip=True)
gawk -F, '{print $1","$2"_"$3","$4","$5","$6","$7","$8","$9","$10}' input.csv
raw_csv = csv.reader(open('file'))
joined_columns = np.array([[[i[0]]+[str(i[1])+'sep_string'+str(i[2])]+i[3:]]
for i in raw_csv])