Python列表争吵

时间:2016-04-08 00:07:47

标签: python csv tableau data-analysis

我的列表看起来像这样

[[x, a, d], [y], [z,f]]

它通过此

争吵
#tag to print is the raw JSON
        for tagElement in tagToPrint[x]:
            if tagElement not in allConstrainedTagList:
                if v == 0:
                    topicTagConcat = [tagElement]
                    topicTagToPrint[x] = tagElement
                    v = v + 1
                elif v >= 1:
                    topicTagConcat = [topicTagConcat, tagElement]
                    topicTagToPrint[x] = topicTagConcat
                    v = v + 1

然后使用此

with open("output.csv", 'wb') as outcsv:
    #configure writer to write standard csv file
    writer = csv.writer(outcsv, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL, lineterminator='\n')
    writer.writerow(['Topic Tag', ..... ])
    while x < y:
        writer.writerow(rowPrinter[x])
        x = x + 1

打印出来

ID ColA ColB ColC
1   X    A    D
2   Y         
3   Z         F

我如何分析A&amp; B&amp; C一起作为一列? X,Y,Z,A,B,C是 同一列。它正在进入画面。

0 个答案:

没有答案