I know the title isn’t informative at all, but I had no idea how to sum up my question. I have 2 spreadsheets, one of them 400+ words paired with a number for each word and the other one has has the text that I will be using. So the first spreadsheet looks like this:
Column A Column B
afds 0
dshs 1
dhid 2
. .
. .
. .
dgsrs 456
And the second spreadsheet looks something like this:
Column A Column B
dhid afds
dshs dgsrs
etc. etc.
I would like to get the second spreadsheet to display the numbers that are assigned to the strings in the first spreadsheet. So I would eventually like to end up with a spreadsheet that looks like this:
Column A Column B
2 (used to be dhid) 0 (used to be afds)
1 (used to be dshs) 456 (used to be dgsrs
(The comments in brackets is just to explain, I don’t want them in the final spreadsheet)
So I started doing find&replace (find a string in the second spreadsheet and replace it with the value that is assigned to it in the first spreadsheet), but I know that there must be a script for this. I am not extremely familiar with any language, but so far I have been able to run simple scripts in languages I hadn’t seen before, so if you know any solution to this, please let me know, I don’t care what programming language it is in, I can google a way to run it as long as it runs on mac os x (c compiler installed).
Thanks in advance!
While you could write a script to do this, the use of a translation table is common enough to be supported in many spreadsheet formula languages. In Excel-flavoured languages — I’ll use OpenOffice on the Mac, although this works with Numbers as well — you can use the function VLOOKUP. Its calling syntax in OO looks like
Probably easier to show it, so:

On the left hand side I put your translation table. In the centre were the cells to be translated. And on the right I wrote the formula VLOOKUP(D3; $A3:$B6; 2; 0), which translates into “look for the value of cell D3 in the translation table in the fixed region from A3-B6, use the second column as the values, and the table isn’t sorted so don’t try to take shortcuts while searching”. Then I simply copied that cell from F3 to the F3:G4 region, to match the shape of the central data columns.
BTW, I can never remember which programs are happy with semicolons and which ones need commas, so you may need to change that.. Seaching for VLOOKUP and whatever program you use should give you all the tutorials you need. I think modern Excel even automates the process.