is an option for SemanticImport and related functions that specifies what should be considered "missing" and what to replace it with.
MissingDataRules
is an option for SemanticImport and related functions that specifies what should be considered "missing" and what to replace it with.
Details
- MissingDataRules->{s1->val1,s2->val2,…} specifies that whenever an element has the form of a string or string pattern si, it should be replaced in the output by a Missing incorporating vali.
- MissingDataRules-><|name1->{s1->val1,…},name2->…,…|> specifies replacements to use in columns with names namei.
- MissingDataRules->{{s1->val1,…},…} specifies replacements to use in successive columns.
- If vali is of the form Missing[…], it is used directly.
- MissingDataRules->Automatic uses heuristics to determine which elements should be considered missing.
Examples
Basic Examples (5)
Specify how to handle missing data:
exampleText = "a a
a aa
aa a
aa aa"Grid[SemanticImportString[exampleText, Automatic, "Rows", MissingDataRules -> {"a" -> Missing["b"]}]]Match missing data by pattern:
exampleText = "a a
a aa
aa a
aa aa"Grid[SemanticImportString[exampleText, Automatic, "Rows", MissingDataRules -> {("a" ~~ __) -> Missing["b"]}]]Handle missing data differently in each column:
exampleText = "a a
a aa
aa a
aa aa"Grid[SemanticImportString[exampleText, Automatic, "Rows", MissingDataRules -> {{("a" ~~ __) -> Missing["b"]}, {"a" -> Missing["c"]}}]]Handle missing data in the second column only:
exampleText = "a a
a aa
aa a
aa aa"Grid[SemanticImportString[exampleText, Automatic, "Rows", MissingDataRules -> {{}, {"a" -> Missing["b"]}}]]Specify how to handle missing data by column name:
exampleText = "c1 c2
a a
a aa
aa a
aa aa"Grid[SemanticImportString[exampleText, Automatic, "Rows", MissingDataRules -> <|"c2" -> {("a" ~~ __) -> Missing["b"]}, "c1" -> {"aa" -> Missing["c"], "a" -> Missing["d"]}|>]]History
Text
Wolfram Research (2014), MissingDataRules, Wolfram Language function, https://reference.wolfram.com/language/ref/MissingDataRules.html.
CMS
Wolfram Language. 2014. "MissingDataRules." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/MissingDataRules.html.
APA
Wolfram Language. (2014). MissingDataRules. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MissingDataRules.html
BibTeX
@misc{reference.wolfram_2026_missingdatarules, author="Wolfram Research", title="{MissingDataRules}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/MissingDataRules.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_missingdatarules, organization={Wolfram Research}, title={MissingDataRules}, year={2014}, url={https://reference.wolfram.com/language/ref/MissingDataRules.html}, note=[Accessed: 12-June-2026]}