python - Mysqldb:IndexError:列表索引超出范围
问题描述
运行以下代码以将 csv 导入 mysql 数据库时,出现错误:
IndexError: list index out of range
我知道我有 12 列和 12 个值,那么错误来自哪里?
csv_data = csv.reader('demofile3.csv')
for row in csv_data:
cursor.execute("INSERT INTO producten(offerId, ean, conditionName, conditionCategory, conditionComment, bundlePricesPrice, fulfilmentDeliveryCode, stockAmount, onHoldByRetailer, fulfilmentType, mutationDateTime, referenceCode) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",(row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11]))
CSV 文件内容(前 2 行,共 47 行):
offerId,ean,conditionName,conditionCategory,conditionComment,bundlePricesPrice,fulfilmentDeliveryCode,stockAmount,onHoldByRetailer,fulfilmentType,mutationDateTime,referenceCode
02822cf7-d29e-4f94-a3f3-29a22007ab16,0655160828881,NEW,NEW,,11.95,24uurs-12,0,false,FBR,2020-11-10 16:51:43.329 UTC,
解决方案
推荐阅读
- java - 通过 POST /login API 实现 Spring Security 登录
- julia - 绘制函数的梯度逼近
- reactjs - React useNavigation 说无法对未安装的组件执行反应状态更新
- loops - 如何编写一个 vbscript 继续检查应用程序是否未运行并停止检查应用程序是否正在运行
- python-3.x - 为所有用户更改 python 和 python3 的默认版本
- excel - 从另一个具有不同日期的工作簿调用宏
- haskell - 如何从 int 列表和 Haskell 中的字符串列表创建字符串列表
- visual-studio - WPF - 保持圆角边框
- python - 如何在熊猫列中保存 str.contains() 的总和?
- python - 难以理解的输入行为