duplicates
This commit is contained in:
parent
5cb34da08c
commit
a138d6cd4a
|
@ -10,11 +10,23 @@ OUTPUT_PATH = "/Volumes/mdrive/computer/projects/csv-to-wiki/output"
|
|||
def csv_to_wiki():
|
||||
print("hello")
|
||||
|
||||
os.system("rm -r {}/*".format(OUTPUT_PATH))
|
||||
|
||||
with open('contacts.csv', 'r') as csv_file:
|
||||
reader = csv.DictReader(csv_file)
|
||||
for row in reader:
|
||||
name = row["Name"]
|
||||
base_name = row["Name"]
|
||||
name = base_name
|
||||
count = 1
|
||||
new_name_found = False
|
||||
while not new_name_found:
|
||||
file_path = os.path.join(OUTPUT_PATH, name + ".md")
|
||||
if os.path.exists(file_path):
|
||||
count = count + 1
|
||||
name = base_name + str(count)
|
||||
else:
|
||||
new_name_found = True
|
||||
|
||||
with open(file_path, 'w') as f:
|
||||
for key, value in row.items():
|
||||
if value:
|
||||
|
|
Loading…
Reference in New Issue