The simplest would be to simply manually use the cow and monkey characters, not the strings:
In[309]:= cow = 1; monkey = 2; {cow, monkey} Out[311]= {1, 2}
But this is probably not what you requested. If you want to automatically convert strings to variables, then what should you do (if I understood the question correctly), you must first convert your strings to characters, since characters can be assigned values and used as variables:
Remove[cow,monkey]; str = {"cow", "monkey"}; str1 = ToExpression /@ str {cow, monkey}
(I assume that the characters cow and monkey not been used / defined). After that, you can use the answer for this question to assign variables based on their positions in str1 . However, the usefulness of this approach is also in doubt.
I think the most important thing is to create the so-called indexed variables , for example
myIndexedVar["cow"] = 1; myIndexedVar["monkey"] = 2;
where myIndexedVar is essentially a hash table of key-value pairs, and the keys are your rows and values that you want to assign to them. If necessary, the process can be automated.
EDIT
To illustrate assignments to such variables, here is a function that automates the following:
assignVariables[varNames_List, values_List, hashName_Symbol ] /; Length[varNames] == Length[values] := MapThread[(hashName[
Here is how you can use it:
In[316]:= assignVariables[str,{{4,2,3},{}},myIndexedVar] Out[316]= {{4,2,3},{}} In[317]:= myIndexedVar["cow"] Out[317]= {4,2,3} In[318]:= myIndexedVar["monkey"] Out[318]= {}
But then again, this is really a hash table, so your question makes sense to me when it is reformulated like this: "I want to create a hash table with string keys. What is the easiest way to do this in Mathematica, add key-value pairs and access to them". The answer seems to be indexed variables, as shown above. You might also find it useful to read DownValues , as they provide a mechanism for indexed variables.