diff --git a/GMiguel/Project02.py b/GMiguel/Project02.py deleted file mode 100644 index 1c9c37a..0000000 --- a/GMiguel/Project02.py +++ /dev/null @@ -1,203 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 - - -import pandas as pd -import datetime -from tabulate import tabulate - -def collectInputFile(gedcom_name): - file = open(gedcom_name, "r") - lines = [] - for line in file: - lines.append(str(line)) - - for idx, line in enumerate(lines): - lines[idx] = line.replace('\n', '').replace('@', '').replace('_MARNM', 'MARR') - input_lines = ['0 NOTE Team-4-Project'] + lines - - return input_lines - -def organizeInput(gedcom_name): - input_lines = collectInputFile(gedcom_name) - - indexes = [] - for idx, line in enumerate(input_lines): - lst = line.strip().split() - if lst[0] == '0': - indexes.append(idx) - - fam_split = [] - for n in range(len(indexes)): - try: - fam_split.append(' '.join(input_lines[indexes[n]:indexes[n+1]])) - except: - continue - - del fam_split[0:2] - - return fam_split - - -def createIndiList(gedcom_name): - fam_split = organizeInput(gedcom_name) - indi_list = [] - for text in fam_split: - sub_text = text.strip().split() - char = list(sub_text[1]) - if char[0] == 'I': - indi_list.append(text) - - return indi_list - -def createFamList(gedcom_name): - fam_split = organizeInput(gedcom_name) - fam_list = [] - for text in fam_split: - sub_text = text.strip().split() - char = list(sub_text[1]) - if char[0] == 'F': - fam_list.append(text) - - return fam_list - - -def createIndividualsDataFrame(gedcom_name): - indi_list = createIndiList(gedcom_name) - - individuals = pd.DataFrame(index = range(len(indi_list)), columns = - ['ID', 'Name', 'Gender', 'Birthday', 'Age', - 'Alive', 'Dead', 'Child', 'Spouse']) - - now = pd.to_datetime('now') - - for idx, indi in enumerate(indi_list): - lst = indi.strip().split() - individuals.ID[idx] = lst[1] - - if "NAME" in lst: - i = lst.index("NAME") - individuals.Name[idx] = ' '.join(lst[i+1:i+3]).replace('/', '') - - if "SEX" in lst: - i = lst.index("SEX") - individuals.Gender[idx] = lst[i+1] - - if "BIRT" in lst: - i = lst.index("BIRT") - date_b = pd.to_datetime('-'.join(lst[i+3:i+6])) - individuals.Birthday[idx] = date_b.strftime("%b-%d-%Y") - - if "DEAT" in lst: - i = lst.index("DEAT") - date_d = pd.to_datetime('-'.join(lst[i+4:i+7])) - individuals.Dead[idx] = date_d.strftime("%b-%d-%Y") - individuals.Age[idx] = int((date_d - date_b).days/365) - individuals.Alive[idx] = 'False' - else: - individuals.Alive[idx] = 'True' - individuals.Age[idx] = int((now - date_b).days/365) - - if "FAMC" in lst: - i = lst.index("FAMC") - individuals.Child[idx] = lst[i+1] - - if "FAMS" in lst: - i = lst.index("FAMS") - individuals.Spouse[idx] = lst[i+1] - - return individuals - - -def createFamiliesDataFrame(gedcom_name): - fam_list = createFamList(gedcom_name) - individuals = createIndividualsDataFrame(gedcom_name) - - families = pd.DataFrame(index = range(len(fam_list)), - columns = ['ID', 'Married', 'Divorced', 'Husband ID', - 'Husband Name', 'Wife ID', 'Wife Name', 'Children']) - - for idx, fam in enumerate(fam_list): - lst = fam.strip().split() - families.ID[idx] = lst[1] - - if "MARR" in lst: - i = lst.index("MARR") - date_d= pd.to_datetime('-'.join(lst[i+3:i+6])) - families.Married[idx] = date_d.strftime("%b-%d-%Y") - - div_case = lst.index("_CURRENT") - if lst[div_case+1] == "N": - families.Divorced[idx] = "True" - else: - families.Divorced[idx] = "False" - - if 'HUSB' in lst: - i = lst.index('HUSB') - families['Husband ID'][idx] = lst[i+1] - families['Husband Name'][idx] = list(individuals.Name[individuals.ID == lst[i+1]])[0] - - if 'WIFE' in lst: - i = lst.index('WIFE') - families['Wife ID'][idx] = lst[i+1] - families['Wife Name'][idx] = list(individuals.Name[individuals.ID == lst[i+1]])[0] - - chil_ids = [idx for idx, val in enumerate(lst) if val in lst[:idx] and val == "CHIL"] - chil_ids = [lst.index("CHIL")] + chil_ids - for n in range(len(chil_ids)): - chil_ids[n] += 1 - chil_ids[n] = lst[chil_ids[n]] - families.Children[idx] = chil_ids - - return families - - -def displayTable(gedcom_name): - individuals = createIndividualsDataFrame(gedcom_name) - families = createFamiliesDataFrame(gedcom_name) - - otp = open("Project03_Output.txt", "w") - otp.truncate(0) - otp.write("Individuals: \n") - otp.write(tabulate(individuals, headers='keys', tablefmt='psql')) - otp.write("\n") - otp.write("Families: \n") - otp.write(tabulate(families, headers='keys', tablefmt='psql')) - otp.close() - -def displayOutput(gedcom_name): - supported = ['INDI', '0 NOTE', '0 HEAD', '0 TRLR', 'FAM', '1 NAME', '1 SEX', '1 BIRT', '1 DEAT', '1 FAMC', - '1 FAMS', '1 MARR', '1 HUSB', '1 WIFE', '1 CHIL', '1 DIV', '2 DATE'] - - output_lines = [] - input_lines = collectInputFile(gedcom_name) - for line in input_lines: - if any(s in line for s in supported): - t = line.strip().split() - if 'INDI' in t: - idx = t.index('INDI') - output_lines.append('|'.join([t[0]] + [t[idx]] + ['Y'] + [' '.join(t[1:idx])])) - elif 'FAM' in t: - idx = t.index('FAM') - output_lines.append('|'.join([t[0]] + [t[idx]] + ['Y'] + [' '.join(t[1:idx])])) - else: - output_lines.append('|'.join(t[0:2] + ['Y'] + [' '.join(t[2:])])) - else: - t = line.strip().split() - output_lines.append('|'.join(t[0:2] + ['N'] + [' '.join(t[2:])])) - - - otp = open("outputProject02.txt", "w") - for n in range(len(input_lines)): - otp.write("\n" + "--> " + input_lines[n]) - otp.write("\n" + "<-- " + output_lines[n] + "\n") - otp.close() - -if __name__ == '__main__': - file_name = input("Enter the name of the GEDCOM file: ") - displayTable(file_name) - - - - - diff --git a/GMiguel/User02_test.py b/GMiguel/User02_test.py deleted file mode 100644 index 109e303..0000000 --- a/GMiguel/User02_test.py +++ /dev/null @@ -1,11 +0,0 @@ -import Project02 -import user02 -import pandas as pd -import unittest - - -class Testuser02(unittest.TestCase): - #all marriages after birth - - def test01(self): - x = "" \ No newline at end of file diff --git a/GMiguel/prev_case03.py b/GMiguel/prev_case03.py deleted file mode 100644 index 66c9aa0..0000000 --- a/GMiguel/prev_case03.py +++ /dev/null @@ -1,10 +0,0 @@ - try: #checks to see if the person is married. - families.Married(index2) - except NameError: - return "not married" - else: - marr_date = families.married(index2) - if marr_date > birthday: - return "Error, birthday is after marriage." - else: - return marr_date \ No newline at end of file diff --git a/GMiguel/sprint1.2 b/GMiguel/sprint1.2 deleted file mode 100644 index e69de29..0000000 diff --git a/GMiguel/sprint1.py b/GMiguel/sprint1.py deleted file mode 100644 index b0e587c..0000000 --- a/GMiguel/sprint1.py +++ /dev/null @@ -1,33 +0,0 @@ -import sys -sys.path.append("c:\\Users\\Stevens User\\Documents\\GitHub\\Team-4-Code\\src") -sys.path.append("C:\\Users\\Stevens User\\Documents\\GitHub\\Team-4-Code\\testFiles") -import pandas as pd -import Project02 -import datetime -import copy - -def user02(gedcom_file): - individuals = Project02.createIndividualsDataFrame(gedcom_file) - families = Project02.createFamiliesDataFrame(gedcom_file) - - indiv_list = pd.DataFrame(columns = [individuals.Name, individuals.Birthday]) - fam_list = pd.DataFrame(columns = [families["Wife Name"], families["Husband Name"], families.Married]) - ''' - - for i, row in indiv_list.iterrows(): - for k, row in fam_list.iterrows(): - if indiv_list[individuals.Name][i]== fam_list[families["Wife Name"]][k] or indiv_list[individuals.Name][i]==fam_list[families["Husband Name"]][k]: - if indiv_list[individuals.Birthday][i] == fam_list[families.Married]: - return True - else: - return False - - - ''' - - - print(fam_list) - - -user02("testFiles/test3.ged") - diff --git a/GMiguel/us13test.py b/GMiguel/us13test.py new file mode 100644 index 0000000..1c1f041 --- /dev/null +++ b/GMiguel/us13test.py @@ -0,0 +1,45 @@ +''' +Author: Samantha Inneo +Sprint: Sprint 1 +Use Case: Birth dates of siblings should be more than 8 months apart or less than 2 days apart + (twins may be born one day apart, e.g. 11:59 PM and 12:02 AM the following calendar day) +''' +import sys +import copy +sys.path.append("C:\\Users\\Stevens User\\Documents\\GitHub\\Team-4-Code\\src") +import Project02 +sys.path.append("C:\\Users\\Stevens User\\Documents\\GitHub\\Team-4-Code\\seeds") +import pandas as pd +import datetime + +def siblingsAgeGap(gedcom_name): + # I need to gather all the siblings of each family + # check if their birthdays are more than 8 months apart + # check if their birthdays are less than 2 days apart + #return true if they are valid, false if they are not + eight_months = 240 + two_days = 2 + + individuals = Project02.createIndividualsDataFrame(gedcom_name) + families = Project02.createFamiliesDataFrame(gedcom_name) + + child = [] + children = copy.deepcopy(families[["Children"]]) + indi = copy.deepcopy(individuals[["ID", "Birthday"]]) + for index, row in children.iterrows(): + #indiv = copy.deepcopy(individuals[["Name", "Birthday", "Dead"]]) + if len(row["Children"]) > 1: + for i in row["Children"]: + lst = row["Children"] + for j in lst: + for k, rows in indi.iterrows(): + if lst[j] == rows[individuals["ID"]]: + child.append(rows[individuals["Birthday"]]) + for m in range(len(child)): + child2 = child[:m] + child[m:] + for l in range(len(child2)): + if ((pd.to_datetime(child[k]) - pd.to_datetime(child2[l])) > two_days) and ((pd.to_datetime(child[k]) - pd.to_datetime(child[l])) < eight_months ): + print("invalid: sibling birthdays") + + +siblingsAgeGap("seeds/seed.ged") \ No newline at end of file diff --git a/GMiguel/user02.py b/GMiguel/user02.py deleted file mode 100644 index 0b23391..0000000 --- a/GMiguel/user02.py +++ /dev/null @@ -1,32 +0,0 @@ -import sys -sys.path.append("c:\\Users\\Stevens User\\Documents\\GitHub\\Team-4-Code\\src") -sys.path.append("C:\\Users\\Stevens User\\Documents\\GitHub\\Team-4-Code\\testFiles") -import pandas as pd -import Project02 -from datetime import datetime -import copy - -#this function is to determine if the marriage date is after the birth date -def user02(gedcom_file): - individuals = Project02.createIndividualsDataFrame(gedcom_file) - families = Project02.createFamiliesDataFrame(gedcom_file) - indiv = copy.deepcopy(individuals[["Name", "Birthday"]]) #makes a copy of original inviduals dataframe - print(indiv) - fam = copy.deepcopy(families[["Wife Name", "Husband Name", "Married"]]) - print(fam) - - for i, row in indiv.iterrows(): - for k, rows in fam.iterrows(): - if row["Name"] == rows["Wife Name"] or row["Name"] == rows["Husband Name"]: - if type(rows["Married"]) == float and pd.isna(rows["Married"]): - print("no marriage date") - elif pd.to_datetime(row["Birthday"]) < pd.to_datetime(rows["Married"]: - print("Valid") - else: - print("Invalid") - - #for k, row in fam.iterrows(): - - -user02("testFiles/test6.ged") - diff --git a/GMiguel/user03_test.py b/GMiguel/user03_test.py deleted file mode 100644 index ac5b7c5..0000000 --- a/GMiguel/user03_test.py +++ /dev/null @@ -1,21 +0,0 @@ -import unittest -import pandas as pd -import Project02 -import user03 - -class TestUser03(unittest.TestCase): - #tests that all deaths are after birth -def -''' -if "BIRT" in lst: - i = lst.index("BIRT") - date_b = pd.to_datetime('-'.join(lst[i+3:i+6])) - individuals.Birthday[idx] = date_b.strftime("%b-%d-%Y") - - if "DEAT" in lst: - i = lst.index("DEAT") - date_d = pd.to_datetime('-'.join(lst[i+4:i+7])) - individuals.Dead[idx] = date_d.strftime("%b-%d-%Y") - individuals.Age[idx] = int((date_d - date_b).days/365) - individuals.Alive[idx] = 'False' -''' \ No newline at end of file diff --git a/seeds/test8.ged b/seeds/test8.ged index 6a72dd8..13d3613 100644 --- a/seeds/test8.ged +++ b/seeds/test8.ged @@ -1,196 +1,212 @@ -0 HEAD -1 SOUR Family Echo -2 WWW http://www.familyecho.com/ -1 FILE Family 2 -1 DATE 20 SEP 2020 -1 DEST ANSTFILE -1 GEDC -2 VERS 5.5.1 -2 FORM LINEAGE-LINKED -1 SUBM @I9@ -2 NAME Peter Damianov -1 SUBN -1 CHAR UTF-8 -0 @I1@ INDI -1 NAME John /Smith/ -2 GIVN John -2 SURN Smith -2 _MARNM Smith -1 SEX M -1 BIRT -2 DATE 11 AUG 1965 -1 FAMS @F1@ -1 FAMC @F2@ -0 @I2@ INDI -1 NAME Susan /Jones/ -2 GIVN Susan -2 SURN Jones -2 _MARNM Smith -1 SEX F -1 BIRT -2 DATE 14 AUG 1969 -1 FAMS @F1@ -1 FAMC @F3@ -0 @I3@ INDI -1 NAME Dylan /Smith/ -2 GIVN Dylan -2 SURN Smith -2 _MARNM Smith -1 SEX M -1 BIRT -2 DATE 21 NOV 2002 -1 FAMC @F1@ -0 @I4@ INDI -1 NAME Frank /Jones/ -2 GIVN Frank -2 SURN Jones -2 _MARNM Jones -1 SEX M -1 BIRT -2 DATE 9 APR 1940 -1 FAMS @F3@ -0 @I5@ INDI -1 NAME Emily /Michaels/ -2 GIVN Emily -2 SURN Michaels -2 _MARNM Jones -1 SEX F -1 BIRT -2 DATE 5 OCT 1942 -1 FAMS @F3@ -0 @I6@ INDI -1 NAME Bernard /Smith/ -2 GIVN Bernard -2 SURN Smith -2 _MARNM Smith -1 SEX M -1 BIRT -2 DATE 6 FEB 1940 -1 FAMS @F2@ -0 @I7@ INDI -1 NAME Theresa /Kelly/ -2 GIVN Theresa -2 SURN Kelly -2 _MARNM Smith -1 SEX F -1 BIRT -2 DATE 22 JUL 1941 -1 FAMS @F2@ -0 @I8@ INDI -1 NAME Kevin /Brown/ -2 GIVN Kevin -2 SURN Brown -2 _MARNM Jones -1 SEX M -1 BIRT -2 DATE 30 MAY 1967 -1 FAMS @F4@ -1 FAMS @F5@ -1 FAMC @F3@ -0 @I9@ INDI -1 NAME Diane /Brown/ -2 GIVN Diane -2 SURN Brown -2 _MARNM Jones -1 SEX F -1 BIRT -2 DATE 2 JAN 1970 -1 FAMS @F4@ -0 @I10@ INDI -1 NAME Paul /Smith/ -2 GIVN Paul -2 SURN Smith -2 _MARNM Smith -1 SEX M -1 BIRT -2 DATE 14 JUL 1968 -1 FAMC @F2@ -0 @I11@ INDI -1 NAME James /Jones/ -2 GIVN James -2 SURN Jones -2 _MARNM Jones -1 SEX M -1 BIRT -2 DATE 10 OCT 2007 -1 FAMC @F4@ -0 @I12@ INDI -1 NAME Lucia /Johnson/ -2 GIVN Lucia -2 SURN Johnson -2 _MARNM Jones -1 SEX F -1 BIRT -2 DATE 5 DEC 1967 -1 DEAT Y -2 DATE 11 MAY 2001 -1 FAMS @F5@ -0 @I13@ INDI -1 NAME Michelle /Jones/ -2 GIVN Michelle -2 SURN Jones -2 _MARNM Jones -1 SEX F -1 BIRT -2 DATE 8 MAR 1999 -1 FAMC @F5@ -0 @I14@ INDI -1 NAME Evan /Smith/ -2 GIVN Evan -2 SURN Smith -2 _MARNM Smith -1 SEX M -1 BIRT -2 DATE 10 NOV 1997 -1 FAMC @F1@ -0 @I15@ INDI -1 NAME Matthew /Smith/ -2 GIVN Matthew -2 SURN Smith -2 _MARNM Smith -1 SEX M -1 BIRT -2 DATE 1 JUL 1996 -1 FAMC @F1@ -0 @F1@ FAM -1 HUSB @I1@ -1 WIFE @I2@ -1 CHIL @I3@ -1 CHIL @I14@ -1 CHIL @I15@ -1 MARR -2 DATE 27 JUN 1995 -1 _CURRENT Y -0 @F2@ FAM -1 HUSB @I6@ -1 WIFE @I7@ -1 CHIL @I1@ -1 CHIL @I10@ -1 MARR -2 DATE 7 AUG 1965 -1 _CURRENT Y -0 @F3@ FAM -1 HUSB @I4@ -1 WIFE @I5@ -1 CHIL @I2@ -1 CHIL @I8@ -1 MARR -2 DATE 12 SEP 1965 -1 _CURRENT Y -0 @F4@ FAM -1 HUSB @I8@ -1 WIFE @I9@ -1 CHIL @I11@ -1 MARR -2 DATE 21 MAY 2006 -1 _CURRENT Y -0 @F5@ FAM -1 HUSB @I8@ -1 WIFE @I12@ -1 CHIL @I13@ -1 MARR -2 DATE 20 DEC 1996 -1 EVEN -2 TYPE Ending -1 _CURRENT N -0 TRLR \ No newline at end of file + +0 HEAD +1 SOUR Family Echo +2 WWW http://www.familyecho.com/ +1 FILE My Family +1 DATE 4 OCT 2020 +1 DEST ANSTFILE +1 GEDC +2 VERS 5.5.1 +2 FORM LINEAGE-LINKED +1 SUBM @I1@ +2 NAME Grace Miguel +1 SUBN +1 CHAR UTF-8 +0 @I1@ INDI +1 NAME GRACE /MIGUEL/ +2 GIVN GRACE +2 SURN MIGUEL +2 _MARNM MIGUEL +1 SEX F +1 BIRT +2 DATE 30 JUL 2000 +1 FAMC @F1@ +0 @I2@ INDI +1 NAME ANGEL /MIGUEL/ +2 GIVN ANGEL +2 SURN MIGUEL +2 _MARNM MIGUEL +1 SEX M +1 BIRT +2 DATE 7 JAN 1964 +1 FAMS @F1@ +1 FAMC @F2@ +0 @I3@ INDI +1 NAME DIANA /LAUCELLO/ +2 GIVN DIANA +2 SURN LAUCELLO +2 _MARNM MIGUEL +1 SEX F +1 BIRT +2 DATE 26 JUL 1969 +1 FAMS @F1@ +1 FAMC @F3@ +0 @I4@ INDI +1 NAME ANGEL /Florene/ +2 GIVN ANGEL +2 SURN Florene +2 _MARNM MIGUEL +1 SEX M +1 BIRT +2 DATE 1 MAR 1923 +1 DEAT Y +2 DATE 24 JAN 1920 +1 FAMS @F2@ +1 FAMS @F4@ +1 FAMC @F5@ +0 @I5@ INDI +1 NAME EDITH /JIMENEZ/ +2 GIVN EDITH +2 SURN JIMENEZ +2 _MARNM WRIGHT +1 SEX F +1 BIRT +2 DATE 20 MAR 1930 +1 FAMS @F2@ +1 FAMS @F6@ +0 @I6@ INDI +1 NAME JOSEPH /WRIGHT/ +2 GIVN JOSEPH +2 SURN WRIGHT +2 _MARNM WRIGHT +1 SEX M +1 BIRT +2 DATE 15 JAN 1932 +1 DEAT Y +2 DATE 24 MAY 2013 +1 FAMS @F6@ +0 @I7@ INDI +1 NAME MERCEDES /FUENTES/ +2 GIVN MERCEDES +2 SURN FUENTES +2 _MARNM MIGUEL +1 SEX F +1 BIRT +2 DATE 4 APR 1939 +1 FAMS @F4@ +1 FAMS @F7@ +0 @I8@ INDI +1 NAME JANET /MIGUEL/ +2 GIVN JANET +2 SURN MIGUEL +2 _MARNM MIGUEL +1 SEX F +1 BIRT +2 DATE 9 APR 1975 +1 FAMC @F7@ +0 @I9@ INDI +1 NAME KATHERINE /MIGUEL/ +2 GIVN KATHERINE +2 SURN MIGUEL +2 _MARNM VEGA +1 SEX F +1 BIRT +2 DATE 18 SEP 1966 +1 FAMC @F2@ +0 @I10@ INDI +1 NAME LESLIE /MIGUEL/ +2 GIVN LESLIE +2 SURN MIGUEL +2 _MARNM GOMEZ +1 SEX F +1 BIRT +2 DATE 23 NOV 1961 +1 FAMC @F2@ +0 @I11@ INDI +1 NAME VICTOR /LAUCELLO/ +2 GIVN VICTOR +2 SURN LAUCELLO +2 _MARNM LAUCELLO +1 SEX M +1 BIRT +2 DATE 22 NOV 1945 +1 FAMS @F3@ +0 @I12@ INDI +1 NAME JUANITA /FERRER/ +2 GIVN JUANITA +2 SURN FERRER +2 _MARNM LAUCELLO +1 SEX F +1 BIRT +2 DATE 13 DEC 1943 +1 FAMS @F3@ +0 @I13@ INDI +1 NAME DARIA /LAUCELLO/ +2 GIVN DARIA +2 SURN LAUCELLO +2 _MARNM SOLLER +1 SEX F +1 BIRT +2 DATE 11 MAR 1977 +1 FAMC @F3@ +0 @I14@ INDI +1 NAME ELISE /MIGUEL/ +2 GIVN ELISE +2 SURN MIGUEL +2 _MARNM MIGUEL +1 SEX F +1 BIRT +2 DATE 17 JUL 1997 +1 FAMC @F1@ +0 @I15@ INDI +1 NAME +1 SEX M +1 FAMS @F5@ +0 @I16@ INDI +1 NAME JULIA /HERMINEZ/ +2 GIVN JULIA +2 SURN HERMINEZ +2 _MARNM MIGUEL +1 SEX F +1 BIRT +2 DATE 7 APR 1900 +1 DEAT Y +2 DATE 21 NOV 1990 +1 FAMS @F5@ +0 @F1@ FAM +1 HUSB @I2@ +1 WIFE @I3@ +1 CHIL @I1@ +1 CHIL @I14@ +1 MARR +2 DATE 7 JUN 1994 +1 _CURRENT Y +0 @F2@ FAM +1 HUSB @I4@ +1 WIFE @I5@ +1 CHIL @I2@ +1 CHIL @I9@ +1 CHIL @I10@ +1 MARR +1 DIV +1 _CURRENT N +0 @F3@ FAM +1 HUSB @I11@ +1 WIFE @I12@ +1 CHIL @I3@ +1 CHIL @I13@ +1 MARR +2 DATE 9 SEP 1968 +1 _CURRENT Y +0 @F4@ FAM +1 HUSB @I4@ +1 WIFE @I7@ +1 MARR +2 DATE 6 JUN 1956 +1 _CURRENT Y +0 @F5@ FAM +1 HUSB @I15@ +1 WIFE @I16@ +1 CHIL @I4@ +1 MARR +2 DATE 22 MAR 1915 +1 _CURRENT Y +0 @F6@ FAM +1 HUSB @I6@ +1 WIFE @I5@ +1 MARR +1 _CURRENT Y +0 @F7@ FAM +1 WIFE @I7@ +1 CHIL @I8@ +0 TRLR diff --git a/seeds/test9.ged b/seeds/test9.ged index 782bc7f..a6afb9d 100644 --- a/seeds/test9.ged +++ b/seeds/test9.ged @@ -1,196 +1,237 @@ -0 HEAD -1 SOUR Family Echo -2 WWW http://www.familyecho.com/ -1 FILE Family 2 -1 DATE 20 SEP 2020 -1 DEST ANSTFILE -1 GEDC -2 VERS 5.5.1 -2 FORM LINEAGE-LINKED -1 SUBM @I9@ -2 NAME Peter Damianov -1 SUBN -1 CHAR UTF-8 -0 @I1@ INDI -1 NAME John /Smith/ -2 GIVN John -2 SURN Smith -2 _MARNM Smith -1 SEX M -1 BIRT -2 DATE 11 AUG 1965 -1 FAMS @F1@ -1 FAMC @F2@ -0 @I2@ INDI -1 NAME Susan /Jones/ -2 GIVN Susan -2 SURN Jones -2 _MARNM Smith -1 SEX F -1 BIRT -2 DATE 14 AUG 1969 -1 FAMS @F1@ -1 FAMC @F3@ -0 @I3@ INDI -1 NAME Dylan /Smith/ -2 GIVN Dylan -2 SURN Smith -2 _MARNM Smith -1 SEX M -1 BIRT -2 DATE 21 NOV 2002 -1 FAMC @F1@ -0 @I4@ INDI -1 NAME Frank /Jones/ -2 GIVN Frank -2 SURN Jones -2 _MARNM Jones -1 SEX M -1 BIRT -2 DATE 9 APR 1940 -1 FAMS @F3@ -0 @I5@ INDI -1 NAME Emily /Michaels/ -2 GIVN Emily -2 SURN Michaels -2 _MARNM Jones -1 SEX F -1 BIRT -2 DATE 5 OCT 1942 -1 FAMS @F3@ -0 @I6@ INDI -1 NAME Bernard /Smith/ -2 GIVN Bernard -2 SURN Smith -2 _MARNM Smith -1 SEX M -1 BIRT -2 DATE 6 FEB 1940 -1 FAMS @F2@ -0 @I7@ INDI -1 NAME Theresa /Kelly/ -2 GIVN Theresa -2 SURN Kelly -2 _MARNM Smith -1 SEX F -1 BIRT -2 DATE 22 JUL 1941 -1 FAMS @F2@ -0 @I8@ INDI -1 NAME Kevin /Brown/ -2 GIVN Kevin -2 SURN Brown -2 _MARNM Jones -1 SEX M -1 BIRT -2 DATE 30 MAY 1967 -1 FAMS @F4@ -1 FAMS @F5@ -1 FAMC @F3@ -0 @I9@ INDI -1 NAME Diane /Brown/ -2 GIVN Diane -2 SURN Brown -2 _MARNM Jones -1 SEX F -1 BIRT -2 DATE 2 JAN 1980 -1 FAMS @F4@ -0 @I10@ INDI -1 NAME Paul /Smith/ -2 GIVN Paul -2 SURN Smith -2 _MARNM Smith -1 SEX M -1 BIRT -2 DATE 14 JUL 1968 -1 FAMC @F2@ -0 @I11@ INDI -1 NAME James /Jones/ -2 GIVN James -2 SURN Jones -2 _MARNM Jones -1 SEX M -1 BIRT -2 DATE 10 OCT 2007 -1 FAMC @F4@ -0 @I12@ INDI -1 NAME Lucia /Johnson/ -2 GIVN Lucia -2 SURN Johnson -2 _MARNM Jones -1 SEX F -1 BIRT -2 DATE 5 DEC 1967 -1 DEAT Y -2 DATE 11 MAY 2001 -1 FAMS @F5@ -0 @I13@ INDI -1 NAME Michelle /Jones/ -2 GIVN Michelle -2 SURN Jones -2 _MARNM Jones -1 SEX F -1 BIRT -2 DATE 8 MAR 1999 -1 FAMC @F5@ -0 @I14@ INDI -1 NAME Evan /Smith/ -2 GIVN Evan -2 SURN Smith -2 _MARNM Smith -1 SEX M -1 BIRT -2 DATE 10 NOV 1997 -1 FAMC @F1@ -0 @I15@ INDI -1 NAME Matthew /Smith/ -2 GIVN Matthew -2 SURN Smith -2 _MARNM Smith -1 SEX M -1 BIRT -2 DATE 1 JUL 1996 -1 FAMC @F1@ -0 @F1@ FAM -1 HUSB @I1@ -1 WIFE @I2@ -1 CHIL @I3@ -1 CHIL @I14@ -1 CHIL @I15@ -1 MARR -2 DATE 27 JUN 1995 -1 _CURRENT Y -0 @F2@ FAM -1 HUSB @I6@ -1 WIFE @I7@ -1 CHIL @I1@ -1 CHIL @I10@ -1 MARR -2 DATE 7 AUG 1965 -1 _CURRENT Y -0 @F3@ FAM -1 HUSB @I4@ -1 WIFE @I5@ -1 CHIL @I2@ -1 CHIL @I8@ -1 MARR -2 DATE 12 SEP 1965 -1 _CURRENT Y -0 @F4@ FAM -1 HUSB @I8@ -1 WIFE @I9@ -1 CHIL @I11@ -1 MARR -2 DATE 21 MAY 2006 -1 _CURRENT Y -0 @F5@ FAM -1 HUSB @I8@ -1 WIFE @I12@ -1 CHIL @I13@ -1 MARR -2 DATE 20 DEC 1996 -1 EVEN -2 TYPE Ending -1 _CURRENT N +<<<<< +0 HEAD +1 SOUR Family Echo +2 WWW http://www.familyecho.com/ +1 FILE My Family +1 DATE 4 OCT 2020 +1 DEST ANSTFILE +1 GEDC +2 VERS 5.5.1 +2 FORM LINEAGE-LINKED +1 SUBM @I1@ +2 NAME Grace Miguel +1 SUBN +1 CHAR UTF-8 +0 @I1@ INDI +1 NAME GRACE /MIGUEL/ +2 GIVN GRACE +2 SURN MIGUEL +2 _MARNM MIGUEL +1 SEX F +1 BIRT +2 DATE 30 JUL 2000 +1 FAMC @F1@ +0 @I2@ INDI +1 NAME ANGEL /MIGUEL/ +2 GIVN ANGEL +2 SURN MIGUEL +2 _MARNM MIGUEL +1 SEX M +1 BIRT +2 DATE 7 JAN 1964 +1 FAMS @F1@ +1 FAMC @F2@ +0 @I3@ INDI +1 NAME DIANA /LAUCELLO/ +2 GIVN DIANA +2 SURN LAUCELLO +2 _MARNM MIGUEL +1 SEX F +1 BIRT +2 DATE 26 JUL 1969 +1 FAMS @F1@ +1 FAMC @F3@ +0 @I4@ INDI +1 NAME ANGEL /Florene/ +2 GIVN ANGEL +2 SURN Florene +2 _MARNM MIGUEL +1 SEX M +1 BIRT +2 DATE 1 MAR 1923 +1 DEAT Y +2 DATE 24 JAN 1920 +1 FAMS @F2@ +1 FAMS @F4@ +1 FAMC @F5@ +0 @I5@ INDI +1 NAME EDITH /JIMENEZ/ +2 GIVN EDITH +2 SURN JIMENEZ +2 _MARNM WRIGHT +1 SEX F +1 BIRT +2 DATE 20 MAR 1930 +1 FAMS @F2@ +1 FAMS @F6@ +0 @I6@ INDI +1 NAME JOSEPH /WRIGHT/ +2 GIVN JOSEPH +2 SURN WRIGHT +2 _MARNM WRIGHT +1 SEX M +1 BIRT +2 DATE 15 JAN 1932 +1 DEAT Y +2 DATE 24 MAY 2013 +1 FAMS @F6@ +0 @I7@ INDI +1 NAME MERCEDES /FUENTES/ +2 GIVN MERCEDES +2 SURN FUENTES +2 _MARNM MIGUEL +1 SEX F +1 BIRT +2 DATE 4 APR 1939 +1 FAMS @F4@ +1 FAMS @F7@ +1 FAMS @F8@ +0 @I8@ INDI +1 NAME JANET /MIGUEL/ +2 GIVN JANET +2 SURN MIGUEL +2 _MARNM MIGUEL +1 SEX F +1 BIRT +2 DATE 9 APR 1975 +1 FAMC @F8@ +0 @I9@ INDI +1 NAME KATHERINE /MIGUEL/ +2 GIVN KATHERINE +2 SURN MIGUEL +2 _MARNM VEGA +1 SEX F +1 BIRT +2 DATE 18 SEP 1966 +1 FAMC @F2@ +0 @I10@ INDI +1 NAME LESLIE /MIGUEL/ +2 GIVN LESLIE +2 SURN MIGUEL +2 _MARNM GOMEZ +1 SEX F +1 BIRT +2 DATE 23 NOV 1961 +1 FAMC @F2@ +0 @I11@ INDI +1 NAME VICTOR /LAUCELLO/ +2 GIVN VICTOR +2 SURN LAUCELLO +2 _MARNM LAUCELLO +1 SEX M +1 BIRT +2 DATE 22 NOV 1945 +1 FAMS @F3@ +0 @I12@ INDI +1 NAME JUANITA /FERRER/ +2 GIVN JUANITA +2 SURN FERRER +2 _MARNM LAUCELLO +1 SEX F +1 BIRT +2 DATE 13 DEC 1943 +1 FAMS @F3@ +0 @I13@ INDI +1 NAME DARIA /LAUCELLO/ +2 GIVN DARIA +2 SURN LAUCELLO +2 _MARNM SOLLER +1 SEX F +1 BIRT +2 DATE 11 MAR 1977 +1 FAMC @F3@ +0 @I14@ INDI +1 NAME ELISE /MIGUEL/ +2 GIVN ELISE +2 SURN MIGUEL +2 _MARNM MIGUEL +1 SEX F +1 BIRT +2 DATE 17 JUL 1997 +1 FAMC @F1@ +0 @I15@ INDI +1 NAME RAYMOND /MIGUEL/ +2 GIVN RAYMOND +2 SURN MIGUEL +2 _MARNM MIGUEL +1 SEX M +1 BIRT +2 DATE 4 MAR 1899 +1 DEAT Y +2 DATE 11 DEC 1898 +1 FAMS @F5@ +0 @I16@ INDI +1 NAME JULIA /HERMINEZ/ +2 GIVN JULIA +2 SURN HERMINEZ +2 _MARNM MIGUEL +1 SEX F +1 BIRT +2 DATE 7 APR 1900 +1 DEAT Y +2 DATE 21 NOV 1990 +1 FAMS @F5@ +0 @I17@ INDI +1 NAME ANTONIO /FIFA/ +2 GIVN ANTONIO +2 SURN FIFA +2 _MARNM FIFA +1 SEX M +1 BIRT +2 DATE 3 JAN 1934 +1 FAMS @F7@ +0 @F1@ FAM +1 HUSB @I2@ +1 WIFE @I3@ +1 CHIL @I1@ +1 CHIL @I14@ +1 MARR +2 DATE 7 JUN 1994 +1 _CURRENT Y +0 @F2@ FAM +1 HUSB @I4@ +1 WIFE @I5@ +1 CHIL @I2@ +1 CHIL @I9@ +1 CHIL @I10@ +1 MARR +2 DATE 9 SEP 1955 +1 DIV +1 _CURRENT N +0 @F3@ FAM +1 HUSB @I11@ +1 WIFE @I12@ +1 CHIL @I3@ +1 CHIL @I13@ +1 MARR +2 DATE 9 SEP 1968 +1 _CURRENT Y +0 @F4@ FAM +1 HUSB @I4@ +1 WIFE @I7@ +1 MARR +2 DATE 6 JUN 1900 +1 EVEN +2 TYPE Ending +1 _CURRENT N +0 @F7@ FAM +1 HUSB @I17@ +1 WIFE @I7@ +1 _CURRENT Y +0 @F5@ FAM +1 HUSB @I15@ +1 WIFE @I16@ +1 CHIL @I4@ +1 MARR +2 DATE 22 MAR 1915 +1 _CURRENT Y +0 @F6@ FAM +1 HUSB @I6@ +1 WIFE @I5@ +1 MARR +2 DATE 17 FEB 1989 +1 _CURRENT Y +0 @F8@ FAM +1 WIFE @I7@ +1 CHIL @I8@ 0 TRLR \ No newline at end of file diff --git a/src/Project02.py b/src/Project02.py index eca9759..1675ad0 100644 --- a/src/Project02.py +++ b/src/Project02.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python -# coding: utf-8 import pandas as pd import datetime @@ -149,3 +147,49 @@ def createFamiliesDataFrame(gedcom_name): families.Children[idx] = chil_ids return families + + +def displayTable(gedcom_name): + individuals = createIndividualsDataFrame(gedcom_name) + families = createFamiliesDataFrame(gedcom_name) + + otp = open("Project03_Output.txt", "w") + otp.truncate(0) + otp.write("Individuals: \n") + otp.write(tabulate(individuals, headers='keys', tablefmt='psql')) + otp.write("\n") + otp.write("Families: \n") + otp.write(str(families)) + otp.close() + +def displayOutput(gedcom_name): + supported = ['INDI', '0 NOTE', '0 HEAD', '0 TRLR', 'FAM', '1 NAME', '1 SEX', '1 BIRT', '1 DEAT', '1 FAMC', + '1 FAMS', '1 MARR', '1 HUSB', '1 WIFE', '1 CHIL', '1 DIV', '2 DATE'] + + output_lines = [] + input_lines = collectInputFile(gedcom_name) + for line in input_lines: + if any(s in line for s in supported): + t = line.strip().split() + if 'INDI' in t: + idx = t.index('INDI') + output_lines.append('|'.join([t[0]] + [t[idx]] + ['Y'] + [' '.join(t[1:idx])])) + elif 'FAM' in t: + idx = t.index('FAM') + output_lines.append('|'.join([t[0]] + [t[idx]] + ['Y'] + [' '.join(t[1:idx])])) + else: + output_lines.append('|'.join(t[0:2] + ['Y'] + [' '.join(t[2:])])) + else: + t = line.strip().split() + output_lines.append('|'.join(t[0:2] + ['N'] + [' '.join(t[2:])])) + + + otp = open("outputProject02.txt", "w") + for n in range(len(input_lines)): + otp.write("\n" + "--> " + input_lines[n]) + otp.write("\n" + "<-- " + output_lines[n] + "\n") + otp.close() + +if __name__ == '__main__': + file_name = input("Enter the name of the GEDCOM file: ") + displayTable(file_name) diff --git a/src/UserStories/us02.py b/src/UserStories/us02.py new file mode 100644 index 0000000..c03bcf4 --- /dev/null +++ b/src/UserStories/us02.py @@ -0,0 +1,49 @@ +''' +Author: Grace Miguel +I pledge my honor that I've abided by the the Stevens Honor Code. +''' +import sys +import os +sys.path.append(os.path.abspath('../src/UserStories')) + #"c:\\Users\\Stevens User\\Documents\\GitHub\\Team-4-Code\\src") +sys.path.append(os.path.abspath('../src/seeds')) + #"C:\\Users\\Stevens User\\Documents\\GitHub\\Team-4-Code\\seeds") +import pandas as pd +import Project02 +from datetime import datetime +import copy + +#this function is to determine if the marriage date is after the birth date +def user02(gedcom_file): + individuals = Project02.createIndividualsDataFrame(gedcom_file) + families = Project02.createFamiliesDataFrame(gedcom_file) + indiv = copy.deepcopy(individuals[["Name", "Birthday"]]) #makes a copy of original inviduals dataframe + fam = copy.deepcopy(families[["Wife Name", "Husband Name", "Married"]]) + lst = [] + for i, row in indiv.iterrows(): + for k, rows in fam.iterrows(): + if row["Name"] == rows["Wife Name"]: + if type(rows["Married"]) == float and pd.isna(rows["Married"]): + pass + elif pd.to_datetime(row["Birthday"]) < pd.to_datetime(rows["Married"]): + pass + else: + lst.append(row["Wife Name"]) + + if row["Name"] == rows["Husband Name"]: + if type(rows["Married"]) == float and pd.isna(rows["Married"]): + pass + elif pd.to_datetime(row["Birthday"]) < pd.to_datetime(rows["Married"]): + pass + else: + lst.append(row["Husband Name"]) + + if len(lst) > 0: + return "The following people have births after marriage" + str(lst) + else: + return "" + + + + + diff --git a/src/UserStories/us03.py b/src/UserStories/us03.py new file mode 100644 index 0000000..a0d89fe --- /dev/null +++ b/src/UserStories/us03.py @@ -0,0 +1,32 @@ +import sys +import copy +import numpy as np +import pandas as pd +import datetime +import os +sys.path.append(os.path.abspath('../UserStories')) +sys.path.append(os.path.abspath('../src/seeds')) +import Project02 + +#user03 checks to see if birth dates are before death dates. +def user03(gedcom_file): + individuals = Project02.createIndividualsDataFrame(gedcom_file) + indiv = copy.deepcopy(individuals[["Name", "Birthday", "Dead"]]) #makes a copy of original inviduals dataframe + lst = "" + + for index, row in indiv.iterrows(): #iterates through indiv + if type(row["Dead"]) == float and pd.isna(row["Dead"]): #checks if the Dead row is empty + pass + else: + if pd.to_datetime(row["Birthday"]) < pd.to_datetime(row["Dead"]): #if Death date is AFTER birth, it's valid + pass + else: + lst = lst + row["Name"] + " " + #if Death date is BEFORE birth, it's invalid + if len(lst) >0: + return "The following have deaths before birth which is incorrect: " + str(lst) + else: + return "" + + + diff --git a/tests/US03_test.py b/tests/US03_test.py new file mode 100644 index 0000000..ea6da19 --- /dev/null +++ b/tests/US03_test.py @@ -0,0 +1,34 @@ +import unittest +import sys +import os +sys.path.append(os.path.abspath('../src/UserStories') +import us03 +sys.path.append(os.path.abspath('../tests/src/seeds')) + +class TestUser03(unittest.TestCase): + #one death is incorrect + def test1(self): + s = "The following have deaths before birth which is incorrect: ANGEL Florene " + self.assertEquals(s, us03.us03("seeds/test8.ged")) + + #no deaths before births + def test2(self): + s = "" + self.assertEquals(s, us03.us03("seeds/test7.ged")) + #2 deaths before births + def test3(self): + s = "The following have deaths before birth which is incorrect: ANGEL Florene RAYMOND MIGUEL " + self.assertEquals(s, us03.us03("seeds/test9.ged")) + + #no deaths before births + def test4(self): + s = "" + self.assertEquals(s, us03.us03("seeds/test4.ged")) + + #no deaths before births + def test5(self): + s = "" + self.assertEquals(s, us03.us03("seeds/test6.ged")) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/User02_test.py b/tests/User02_test.py new file mode 100644 index 0000000..cae9bbc --- /dev/null +++ b/tests/User02_test.py @@ -0,0 +1,33 @@ +import sys +import unittest +import os +sys.path.append(os.path.abspath('../src')) +sys.path.append(os.path.abspath('../src/seeds')) +sys.path.append("C:\\Users\\Stevens User\\Documents\\GitHub\\Team-4-Code\\GMiguel") +sys.path.append("c:\\Users\\Stevens User\\Documents\\GitHub\\Team-4-Code\\src") +import user02 + + +class Testuser02(unittest.TestCase): + #all marriages after birth + + def test01(self): + s = "" + self.assertEquals(s, user02.user02("seeds/test1.ged")) + + def test02(self): + s = "" + self.assertEquals(s, user02.user02("seeds/test2.ged")) + + def test03(self): + s = "" + self.assertEquals(s, user02.user02("seeds/test3.ged")) + def test04(self): + s = "" + self.assertEquals(s, user02.user02("seeds/test4.ged")) + def test05(self): + s = "" + self.assertEquals(s, user02.user02("seeds/test5.ged")) + +if __name__ == '__main__': + unittest.main()