Created
May 3, 2018 18:58
-
-
Save lewis-carson/e589222d95f80b0972018800fa2af008 to your computer and use it in GitHub Desktop.
This file contains 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 os | |
import csv | |
import re | |
tot = '' | |
for i in os.listdir('csv'): | |
with open('csv/' + i) as f: | |
tot += f.read().replace(',\n', '\n') | |
print(f.read()) | |
open('tot.csv', 'w+').write(tot) | |
tot = [] | |
with open('tot.csv') as csvfile: | |
spamreader = csv.reader(csvfile, delimiter=',', quotechar='|') | |
for row in spamreader: | |
if len(row) == 2: | |
tot.append(row[:2]) | |
#print(row) | |
tot = [x for x in tot if x != []] | |
tot = [x for x in tot if x != ['', ''] ] | |
#print(tot) | |
for i in tot: | |
print(i) | |
open('parse.csv', 'a+').write(i[0] + ',' + i[1] + '\n') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment