Created
June 20, 2016 08:51
-
-
Save dalanlan/75891749fd1d226b5a6b93e9cc66b84a to your computer and use it in GitHub Desktop.
sort csv file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import csv | |
| import sys | |
| import operator | |
| reload(sys) | |
| sys.setdefaultencoding('utf-8') | |
| reader = csv.reader(open(str(sys.argv[1])), delimiter="|") | |
| sortedlist = sorted(reader, key=operator.itemgetter(8)) | |
| with open(str(sys.argv[2]), 'wb') as csvfile: | |
| writer = csv.writer(csvfile, delimiter = "|") | |
| writer.writerows(sortedlist) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment