我目前正在尝试创建一个程序来读取CSV文件,更具体地说是行数据(横列中的数据)
示例数据.csv:
['Time', 'Date', 'Color ', 'Name']
['1pm', '01-01-99', 'blue', 'jack']
['2pm', '02-02-99', 'green', 'kevin']
['3pm', '03-03-99', 'yellow', 'phil']
['4pm', '04-04-99', 'white', 'alice']
['5pm', '05-05-99', 'black', 'bob']
这是我的密码:
import csv
with open('Sampledata.csv', 'r') as csvfile :
regnumber = input("What is your regnumber?")
reader = csv.reader(csvfile, delimiter=',')
for row in reader:
print(row) # here lies the problem(python is reading columnal data (data going down) instead of row(lines across) data#
问题在于读取列(数据向下)。Python读取列。你知道吗
输出:
Date
01-01-99
02-02-99
03-03-99
04-04-99
05-05-99
这就是你要找的那个吗?你知道吗
上面的代码逐行打印csv文件中的值。你知道吗
相关问题 更多 >
编程相关推荐