repl.it
@LeonGrin/

Names - Gender Detection API

Python

No description

fork
loading
Files
  • main.py
  • all_names.csv
  • defs.py
  • female_names.csv
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import csv, defs

# Reading the csv file and converting the content into a list
with open("all_names.csv", "r") as all_names:
    content = csv.reader(all_names)
    next(content) #Skip the header
    csv_list = []
    for item in content:
        csv_list += item

    with open("female_names.csv", "a") as female_names:
      csv_writer = csv.writer(female_names)

# Separating the first and last name of the list to use the API (function in file defs.py) and get only the female names
      for names in csv_list:
        f_list = []
        split = names.split()
        first = (split[0])
        second = (split[1])
        f_name = defs.female_names(first, second)
        if f_name == False:
          continue
        else:
          csv_writer.writerow([f"{f_name}"])
        


# Separating the first and last name of the list to use the API (function in file defs.py) and get only the female names
'''
for names in csv_list:
  f_list = []
  split = names.split()
  first = (split[0])
  second = (split[1])
  f_name = defs.female_names(first, second)
  if f_name == False:
    continue
  else:
    with open("female_names.csv", "a", newline="") as female_names:
      csv_writer = csv.writer(female_names, delimiter=",")
      csv_writer.writerow(f"{f_name}")
'''