csv - Read Excel lines into Python -


i want import data lines saved in excel csv. how can save each line's data list?

the excel file has following type of data:

name   b  c   d itemid 3  3   4 height 5  5   7 length 6  5   8 

i want save [b,c,d] in list named name, , [3,3,4] list named itemid. tried used following code, returns last line of file.

f = open('part.csv', 'r') csv_f=csv.reader(f,delimiiter=',') row in csv_f:     name.append(row[1])     numid.append(row[2])     height.append(row[3])     length.append(row[4]) 

highly recommend consider using pandas python data analysis library.

import pandas pd  csv_df = pd.read_csv('part.csv') df_t = csv_df.t  print df_t['itemid'].tolist() print df_t.index.tolist() 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -