elliotchance / gedcom

👪 A Go library and CLI tools for encoding, decoding, traversing, merging, comparing, querying and publishing GEDCOM files.
MIT License
98 stars 22 forks source link

Returning the @Identifier of a .Parents field only returns a single value, not two #321

Open jexp opened 2 years ago

jexp commented 2 years ago

I'm confused when I'm looking at a .Parents or .Spouses field then returning the raw data returns everything in an odd textual format

but if I ask for the .Identifier, I get only one

./gedcom query -format csv -gedcom ~/Downloads/pres2020.ged '.Individuals | { name: .Name | .String, born: .Birth | .String, died: .Death | .String, id: .Identifier, sex:.Sex, parents:.Parents | .Identifier, parentNames:.Parents }' | head -3
born,died,id,name,parentNames,parents,sex
,,@I2184@,Paul Stobbe,[],[],Male
19 Aug 1946,,@I1@,William Jefferson Clinton,"[William Jefferson Blythe II (b. 27 Feb 1918, d. 17 May 1946) ⚭ Virginia Dell Cassidy (b. 6 Jun 1923, d. Jan 1994)]",[@F2@],Male

Any ideas what I'm doing wrong?

elliotchance commented 2 years ago

.Parents returns a slice FamilyNode. Each FamilyNode is formatted with marriage/divorce symbols between the Individuals (see https://github.com/elliotchance/gedcom/blob/v38.0.0/family_node.go#L355-L368), so it's string representation of saying "William (born in 1918) is married to Virginia (born in 1923)"

Edit: [@F2@] actually means a list with one item of @F2@. If there were two families it might look like [@F2@,@F3@].