Skip to content

Commit

Permalink
Add support for personal contact details
Browse files Browse the repository at this point in the history
  • Loading branch information
1ukastesar committed Aug 28, 2023
1 parent 52f6e3a commit a8876aa
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@
# CONSTANTS for later use

SKIP_ROWS = 6
USE_COLS = [0, 1, 2, 4, 7, 8, 9, 10, 11]
USE_COLS = [0, 1, 2, 4, 7, 8, 9, 10, 11, 12, 13]

COL_RENAME_RULES = {
"Jméno": "Given Name",
"Příjmení": "Family Name",
"Přezdívka": "Nickname",
"Jednotka": "Group Membership",
"Kategorie": "Category",
"Otec: mail": "E-mail 1 - Value",
"Matka: mail": "E-mail 2 - Value",
"Otec: telefon": "Phone 1 - Value",
"Matka: telefon": "Phone 2 - Value"
"E-mail (hlavní)": "E-mail 1 - Value",
"Otec: mail": "E-mail 2 - Value",
"Matka: mail": "E-mail 3 - Value",
"Telefon / mobil (hlavní)": "Phone 1 - Value",
"Otec: telefon": "Phone 2 - Value",
"Matka: telefon": "Phone 3 - Value",
}

ADD_COLS = [
Expand Down Expand Up @@ -54,10 +56,12 @@
[24, "Notes", ""],
[25, "Language", ""],
[26, "Photo", ""],
[28, "E-mail 1 - Type", "Otec"],
[30, "E-mail 2 - Type", "* Matka"],
[32, "Phone 1 - Type", "Otec"],
[34, "Phone 2 - Type", "* Matka"]
[28, "E-mail 1 - Type", "Dítě"],
[29, "Phone 1 - Type", "Dítě"],
[30, "E-mail 2 - Type", "Otec"],
[31, "Phone 2 - Type", "Otec"],
[32, "E-mail 3 - Type", "* Matka"],
[33, "Phone 3 - Type", "* Matka"],
]

GRPMEM_SEPARATOR = " ::: "
Expand Down Expand Up @@ -102,7 +106,9 @@ def die(error):
input = pd.read_excel(input_path,
skiprows = range(0,SKIP_ROWS),
usecols = USE_COLS,
dtype={"Matka: telefon": str, "Otec: telefon": str})
dtype={"Matka: telefon": str,
"Otec: telefon": str,
"Telefon / mobil (hlavní)": str})
except FileNotFoundError:
die("Input file not found.")
except IOError:
Expand Down Expand Up @@ -136,6 +142,7 @@ def die(error):
# - add +420 in the beginning of telephone numbers to be recognized correctly
input["Phone 1 - Value"] = "+420" + input["Phone 1 - Value"].astype(str)
input["Phone 2 - Value"] = "+420" + input["Phone 2 - Value"].astype(str)
input["Phone 3 - Value"] = "+420" + input["Phone 3 - Value"].astype(str)

# - remove "+420nan", whichever cells is it in (this is a result of an empty phone number cell on the input)
input.replace("+420nan", "", inplace = True)
Expand Down

0 comments on commit a8876aa

Please sign in to comment.