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 index 109e303..16698f2 100644 --- a/GMiguel/User02_test.py +++ b/GMiguel/User02_test.py @@ -1,11 +1,31 @@ -import Project02 -import user02 -import pandas as pd +import sys import unittest +sys.path.append("C:\\Users\\Stevens User\\Documents\\GitHub\\Team-4-Code\\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): - x = "" \ No newline at end of file + 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() diff --git a/GMiguel/sprint1.2 b/GMiguel/sprint1.2 deleted file mode 100644 index e69de29..0000000 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 index 0b23391..48ebe0d 100644 --- a/GMiguel/user02.py +++ b/GMiguel/user02.py @@ -1,6 +1,10 @@ +''' +Author: Grace Miguel +I pledge my honor that I've abided by the the Stevens Honor Code. +''' 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") +sys.path.append("C:\\Users\\Stevens User\\Documents\\GitHub\\Team-4-Code\\seeds") import pandas as pd import Project02 from datetime import datetime @@ -11,22 +15,31 @@ 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) - + lst = [] 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 row["Name"] == rows["Wife 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") + pass + elif pd.to_datetime(row["Birthday"]) < pd.to_datetime(rows["Married"]): + pass else: - print("Invalid") + 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 "" #for k, row in fam.iterrows(): -user02("testFiles/test6.ged") diff --git a/GMiguel/user03.py b/GMiguel/user03.py index 2863c1b..137aeb8 100644 --- a/GMiguel/user03.py +++ b/GMiguel/user03.py @@ -1,11 +1,10 @@ -<<<<<<< HEAD import sys import copy import numpy as np import pandas as pd import datetime 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") +sys.path.append("C:\\Users\\Stevens User\\Documents\\GitHub\\Team-4-Code\\seeds") import Project02 #user03 checks to see if birth dates are before death dates. @@ -19,53 +18,14 @@ def user03(gedcom_file): pass else: if pd.to_datetime(row["Birthday"]) < pd.to_datetime(row["Dead"]): #if Death date is AFTER birth, it's valid - print("Valid") - print(row["Birthday"],row["Dead"] ) - + pass else: lst = lst + row["Name"] + " " - print("Invalid") #if Death date is BEFORE birth, it's invalid - print( row["Birthday"],row["Dead"]) + #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 "" - print("The following have deaths before birth which is incorrect: " + lst) - - -user03("testFiles/test6.ged") -''' - if "BIRT" in lst: - i = lst.index("BIRT") - date_b = datetime.datetime.strptime(" ".join(lst[i+3:i+6]),'%d %b %Y') - individuals.Birthday[idx] = date_b - #edited date_b -''' -======= -import sys -import copy -import numpy as np -import pandas as pd -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 Project02 - -def user03(gedcom_file): - individuals = Project02.createIndividualsDataFrame(gedcom_file) - indiv = copy.deepcopy(individuals[["Birthday", "Dead"]]) - - for index, row in indiv.iterrows(): - if type(row["Dead"]) == float and pd.isna(row["Dead"]): - pass - else: - if row["Birthday"] < row["Dead"]: - print("Valid") - print(row["Birthday"],row["Dead"] ) - - else: - print("Invalid") - print( row["Birthday"],row["Dead"]) - - - -user03("testFiles/test6.ged") ->>>>>>> 6ebe73b8fc1f0478326903651dcc4e954f73e9a8 diff --git a/GMiguel/user03_test.py b/GMiguel/user03_test.py index ac5b7c5..a51c310 100644 --- a/GMiguel/user03_test.py +++ b/GMiguel/user03_test.py @@ -1,21 +1,36 @@ import unittest -import pandas as pd +import sys +sys.path.append("C:\\Users\\Stevens User\\Documents\\GitHub\\Team-4-Code\\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 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 + #one death is incorrect + def test1(self): + s = "The following have deaths before birth which is incorrect: ANGEL Florene " + self.assertEquals(s, user03.user03("seeds/test8.ged")) + + #no deaths before births + def test2(self): + s = "" + self.assertEquals(s, user03.user03("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, user03.user03("seeds/test9.ged")) + + #no deaths before births + def test4(self): + s = "" + self.assertEquals(s, user03.user03("seeds/test4.ged")) + + #no deaths before births + def test5(self): + s = "" + self.assertEquals(s, user03.user03("seeds/test6.ged")) + +if __name__ == '__main__': + unittest.main() + diff --git a/Project03_Output.txt b/Project03_Output.txt index d1a62c0..517a769 100644 --- a/Project03_Output.txt +++ b/Project03_Output.txt @@ -9,10 +9,7 @@ Individuals: | 4 | I5 | Patrick Smith | nan | Feb-02-2018 | 2 | True | nan | F1 | nan | +----+------+---------------+----------+-------------+-------+---------+--------+---------+----------+ Families: -+----+------+-----------+------------+--------------+----------------+-----------+--------------+--------------+ -| | ID | Married | Divorced | Husband ID | Husband Name | Wife ID | Wife Name | Children | -|----+------+-----------+------------+--------------+----------------+-----------+--------------+--------------| -| 0 | F1 | nan | False | I1 | Sam Smith | I4 | Alexa Smith | ['I5'] | -| 1 | F2 | nan | False | I2 | Rick Smith | I3 | Hannah Smith | ['I1', 'I4'] | -| 2 | F3 | nan | True | nan | nan | nan | nan | ['I3'] | -+----+------+-----------+------------+--------------+----------------+-----------+--------------+--------------+ \ No newline at end of file + ID Married Divorced Husband ID Husband Name Wife ID Wife Name Children +0 F1 NaN False I1 Sam Smith I4 Alexa Smith [I5] +1 F2 NaN False I2 Rick Smith I3 Hannah Smith [I1, I4] +2 F3 NaN True NaN NaN NaN NaN [I3] \ No newline at end of file diff --git a/seeds/test8.ged b/seeds/test8.ged new file mode 100644 index 0000000..f3d1419 --- /dev/null +++ b/seeds/test8.ged @@ -0,0 +1,211 @@ +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 new file mode 100644 index 0000000..a594fa2 --- /dev/null +++ b/seeds/test9.ged @@ -0,0 +1,236 @@ +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 diff --git a/src/Project02.py b/src/Project02.py index 164c1a8..2d26bbb 100644 --- a/src/Project02.py +++ b/src/Project02.py @@ -121,13 +121,15 @@ def createFamiliesDataFrame(gedcom_name): if "MARR" in lst: i = lst.index("MARR") - families.Married[idx] = pd.to_datetime('-'.join(lst[i+3:i+6])).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 lst[i+1]=="2": + date_m = pd.to_datetime('-'.join(lst[i+3:i+6])) + families.Married[idx] = date_m.strftime("%b-%d-%Y") + if "_CURRENT" in lst: + 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') @@ -138,13 +140,13 @@ def createFamiliesDataFrame(gedcom_name): 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 + if "CHIL" in lst: + 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 @@ -159,7 +161,7 @@ def displayTable(gedcom_name): otp.write(tabulate(individuals, headers='keys', tablefmt='psql')) otp.write("\n") otp.write("Families: \n") - otp.write(tabulate(families, headers='keys', tablefmt='psql')) + otp.write(str(families)) otp.close() def displayOutput(gedcom_name):