【问题标题】:How to read a GEDCOM file with Julia?如何使用 Julia 读取 GEDCOM 文件?
【发布时间】:2020-07-01 18:46:30
【问题描述】:

我有一个从 Ancestral Quest 导出的带有我的家谱的 GEDCOM 文件,它非常广泛,我想对其进行一些分析。我想构建一个树形结构,并递归地探索它。

是否有任何库可以读取 GEDCOM 文件并创建树结构或某种类型的有向图?

【问题讨论】:

    标签: tree julia gedcom


    【解决方案1】:

    您可以使用 python-gendom 解析文件并将其转换为 LightGraphs 的图形。随后 GraphPlot 可用于实际制作绘图。

    下面是一个工作代码框架:

    using PyCall
    using Conda
    using LightGraphs
    run(`$(PyCall.python) -m pip install python-gedcom`)
    gedcom = pyimport("gedcom")
    gparser = pyimport("gedcom.parser")
    gedcom_parser = gparser.Parser()
    # download from "https://www.gedcom.org/samples/555SAMPLE.GED"
    gedcom_parser.parse_file("c:/temp/555SAMPLE.GED")
    g = SimpleDiGraph()
    for el in gedcom_parser.get_root_child_elements()
        display(el)
        # todo populate graph g
        # recursively iterate over tree
        # see https://pypi.org/project/python-gedcom/ for more details how to read the data
    end
    # todo use GraphPlot to plot the graph 
    

    【讨论】:

    • 太棒了,我只在run($(PyCall.python) 之前包含pyimport_conda("pip", "pip") -m pip install python-gedcom)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-29
    • 2017-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多