Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ipumspy"
version = "0.8.0"
version = "0.8.1"
description = "A collection of tools for working with IPUMS data"
authors = ["Kevin H. Wilson <kevin_wilson@brown.edu>",
"Renae Rodgers <rodge103@umn.edu>"]
Expand Down
2 changes: 1 addition & 1 deletion src/ipumspy/api/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ def build(self) -> Dict[str, Any]:
}

# XXX shoehorn fix until server-side bug is fixed
if self.collection == "meps" or self.collection == "dhs":
if self.collection in ["meps", "dhs", "mtus", "ahtus"]:
for variable in built["variables"].keys():
built["variables"][variable].pop("attachedCharacteristics")

Expand Down
18 changes: 16 additions & 2 deletions src/ipumspy/ddi.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,19 +231,33 @@ def read(cls, elt: Element, ddi_namespace: str) -> FileDescription:
rts = [rectype.attrib["rectype"] for rectype in file_rectypes]
except KeyError:
rts = []
# rectype get rectype id var and rectype key var
# (old ddi ordering of record types): rectype get rectype id var and rectype key var
# these should be the same across record types for all collections
# so we should be fine to just grab the first appearance of recidvar and keyvar
# so we should be fine to just grab the last appearance of recidvar and keyvar
# (the first appearance now is the top level record type, which does not have
# the keyvar attribute - so now grabbing from the last record type in the hierarchy)
try:
rectype_idvar = elt.find("./ddi:fileStrc/ddi:recGrp", namespaces).attrib[
"recidvar"
]
rectype_keyvar = elt.find("./ddi:fileStrc/ddi:recGrp", namespaces).attrib[
"keyvar"
]
# (new ddi ordering of rectypes): if we get a key error, the first appearance now is
# the top level record type, which does not have the keyvar attribute -
# so now grabbing from the last record type in the hierarchy
except KeyError:
rectype_idvar = elt.findall("./ddi:fileStrc/ddi:recGrp", namespaces)[
-1
].attrib["recidvar"]
rectype_keyvar = elt.findall("./ddi:fileStrc/ddi:recGrp", namespaces)[
-1
].attrib["keyvar"]
# if we get an Attribute Error, this is a rectangular file
except AttributeError:
rectype_idvar = ""
rectype_keyvar = ""

return cls(
filename=elt.find("./ddi:fileName", namespaces).text,
description=elt.find("./ddi:fileCont", namespaces).text,
Expand Down
Loading
Loading