How to sort the rows of an csv file?

Viewed 88

Im trying to sort the rows of my csv file.

This is my code:

import os
import csv

my_path = r'c:\data\FF\Desktop\my_files\Zipped' 

for file in os.listdir(my_path):
    path_file = os.path.join(my_path, file)
    with open(path_file, 'r') as output:
        reader = csv.reader(output, delimiter = ',')
        read = [row for row in reader if row] 
        for row in read:
            if len(row) > 9:
                if row[9] == '3086':
                    print(row[25] + '-----'  + sorted(row[0]))

This is my output:

Traceback (most recent call last):

  File "C:\data\FF\Desktop\Python\\untitled2.py", line 14, in <module>
    print(row[25] +  sorted(row[0]))

TypeError: can only concatenate str (not "list") to str
0 Answers
Related