I have a table:
codebook={{1, "BO4675365"}, {2, "4581X0DM7"}, {3, "BR8983933"}, {4, "BR2057668"}, {5, "BN7431495"}, {6, "BG1120297"}, {7, "ZN796880"}, {8, "BO9805678"}, {9, "BJ4669187"}, {10, "BM0350801"}, {11, "ZQ6021518"}, {12, "BV671559"}, {13, "BO3833387"}, {14, "BU6273025"}, {15, "BQ1964585"}, {16, "BM7272362"}, {17, "ZP1747481"}, {18, "BZ314326"}, {19, "ZM5972504"}, {20, "UV8801572"}}
To "read" the code, I search for the alphanumeric entry, and read the corresponding value
Select[codebook, #[[2]] == "4581X0DM7" &] // AbsoluteTiming
which gives (for a table with 7209 entries),
{0.021373, {{2, "4581X0DM7"}}}
So to read the entry number, I use,
Select[codebook, #[[2]] == "4581X0DM7" &][[1, 1]]
which gives
2
Is there a faster way of picking the right entry? Running this millions of times may be trouble. Basically I'm looking for the fastest way to read from a table and get a code.