3 回答
TA贡献2019条经验 获得超9个赞
如果您知道每行中有固定数量的项目:
import csv
with open('myfile.csv') as csvfile:
rows = csv.reader(csvfile)
res = list(zip(*rows))
print(res)
TA贡献1765条经验 获得超5个赞
我会尝试使用 numpy 将 csv 作为数组读取。
from numpy import genfromtxt
p = genfromtxt('myfile.csv', delimiter=',')
cv2.polylines(img,p,True,(0,255,255))
如果您需要将数据强制转换为特定格式,则可能必须将 dtype 参数传递给 genfromtext。
https://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html
TA贡献2041条经验 获得超4个赞
您可能需要单独绘制每条折线(以扩展@Chris 的答案):
from numpy import genfromtxt
lines = genfromtxt('myfile.csv', delimiter=',')
for line in lines:
cv2.polylines(img, line.reshape((-1, 2)), True, (0,255,255))
添加回答
举报
