Read Excel lines into Python

Viewed 133

I want to import the data lines saved in an Excel CSV. How can I save each line's data as a list?

The Excel file has the following type of data:

Name   B  C   D
ItemID 3  3   4
Height 5  5   7
Length 6  5   8

I want to save [B,C,D] in a list named Name, and [3,3,4] as a list named ItemID. I tried to used the following code, but it always returns the last line of the file.

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