Get rows when trying to access columns in a python script -


i'm having problem seems answer explained. i'm improting csv file rows , columns using code:

import csv import os import glob import numpy np  def get_data(filename):     open(filename, 'r') f:         reader = csv.reader(f)                               return list(reader)  all_data = []  path=raw_input('what directory?')        infile in glob.glob(os.path.join(path, '*.csv')):      all_data.extend(get_data(infile)) = np.array(all_data) col=a[:,[0,1]] print col 

however result produces first 2 rows rather columns?

the problem data. verify csv data read correctly (debug reader).

when run script following input files:

file1.csv

foo,bar,baz 1,2,3 2,3,4 3,4,5 

file2.csv

4,5,6 5,6,7 6,7,8 

then result of script following:

$ python test.py [['4' '5']  ['5' '6']  ['6' '7']  ['foo' 'bar']  ['1' '2']  ['2' '3']  ['3' '4']] 

therefore think bug must reading csv files. maybe column separator isn't working correctly.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -