If you have ever cleaned up a parts list for a process plant, you know the problem. One line says "Inconel 625", the next says "Alloy 625", a drawing says "UNS N06625", and a European supplier writes "2.4856". All four mean the same material, but a plain string match treats them as four different things.
This post builds a small Python lookup that maps those names to one record. It is a good exercise in normalizing messy input, and the same pattern works for any catalog with aliases.
The data
Each alloy gets one record keyed by its UNS number. The record holds the common names, the EN material number, and the ASTM product specification for each form.
import re
ALLOYS = {
"N06625": {"names": ["Inconel 625", "Alloy 625"], "en": "2.4856",
"specs": {"plate/sheet": "ASTM B443",
"seamless pipe/tube": "ASTM B444",
"bar": "ASTM B446"}},
"N06600": {"names": ["Inconel 600", "Alloy 600"], "en": "2.4816",
"specs": {"plate/sheet": "ASTM B168",
"seamless pipe/tube": "ASTM B167",
"bar": "ASTM B166"}},
"N10276": {"names": ["Hastelloy C276", "Alloy C-276"], "en": "2.4819",
"specs": {"plate/sheet": "ASTM B575",
"seamless pipe/tube": "ASTM B622",
"bar": "ASTM B574"}},
"N04400": {"names": ["Monel 400", "Alloy 400"], "en": "2.4360",
"specs": {"plate/sheet": "ASTM B127",
"seamless pipe/tube": "ASTM B165",
"bar": "ASTM B164"}},
"N08825": {"names": ["Incoloy 825", "Alloy 825"], "en": "2.4858",
"specs": {"plate/sheet": "ASTM B424",
"seamless pipe/tube": "ASTM B423",
"bar": "ASTM B425"}},
}
Normalizing the input
The trick is to reduce every spelling to one key. Lowercase the text, drop everything except letters, digits and dots, and strip a leading "uns". That handles the registered-trademark sign, hyphens, spaces and the "UNS" prefix in one step.
def norm(text):
text = re.sub(r"[^a-z0-9.]", "", text.lower())
return text.removeprefix("uns")
INDEX = {}
for uns, info in ALLOYS.items():
for key in [uns, info["en"], *info["names"]]:
INDEX[norm(key)] = uns
def lookup(query):
uns = INDEX.get(norm(query))
return (uns, ALLOYS[uns]) if uns else None
Trying it
for q in ["Inconel® 625", "UNS N10276", "2.4819", "alloy c-276", "Monel 400", "nope"]:
hit = lookup(q)
print(q, "->", hit[0] if hit else None)
Output:
Inconel® 625 -> N06625
UNS N10276 -> N10276
2.4819 -> N10276
alloy c-276 -> N10276
Monel 400 -> N04400
nope -> None
Every spelling lands on the same UNS key, and an unknown name returns None instead of a wrong guess.
Where this breaks
- Similar names. "Alloy 625" is safe, but "Alloy 20" or "Alloy 400" can collide with other numbering systems. Keep the alias list explicit instead of guessing.
- Grades inside one family. Hastelloy C-276 and C-22 differ, so never match on a shared prefix like "hastelloy".
- Condition and form. The same alloy can be annealed, aged or cold worked. The lookup identifies the material, not the delivery condition, so keep that as a separate field.
- Edition years. Specifications are revised. Check the current ASTM edition before putting a number on a purchase order.
Extending it
Add one dict entry per alloy and the index builds itself. For a real parts list, read the names from a CSV with csv.DictReader, run each cell through lookup(), and write unmatched lines to a review file for a person to check.
If you work on the buying side and want to see how these grades are sold in practice, the Inconel alloy products at ZHX Steel page lists the common forms and sizes.
This post was written with AI assistance and checked by the author.
Top comments (0)