我想对csv文件(A到Z)的数据进行排序。但它显示错误

时间:2016-04-21 07:06:13

标签: python python-3.x

我的代码是

import sys
import csv
import operator
data = csv.reader(open("clean.csv","r"))
sortedlist = sorted(data, key=operator.itemgetter(0))
with open("Final42.csv", "w") as sorter:
    fileWriter = csv.writer(sorter)
    for row in sortedlist:
        fileWriter.writerow(row)

我收到错误 IndexError:列表索引超出范围

样本数据

  • 2 /,140,​​0.566,455,1069,1.097,1584,0.38,1.989,85.71%,0.1,79.4
  • 01_Launch,140,0.566,455,1069,1.097,1584,0.38,1.989,85.71%,0.1,79.4
  • 109 /api/Login,140,​​0.03,30,34,0.035,43,0.026,0.048,0.00%,0.1,0.1
  • 110 /api/ProspectDashBoard,140,​​0.008,7,8,0.009,22,0.005,0.22,0.00%,0.1,0.7

我的csv文件包含2000行和12列

0 个答案:

没有答案