I appoligize I don't think I have done a very good job of explaining my problem.
I work in the an insurance company that sells non standard auto. We have an in house policy management system that uses MySQL for the data storage. An individual policy consists of a policy header and 1 to n drivers, 1 to n vehicles and 1 to n coverage records per vehicle. A third party company will sell a policy and place it with our company. They collect all of the information on their system and then send this information to us as a CSV file (one file per policy). **This CSV file is like an XML file and is formated as followes; 1st field is a tagname 2nd field is a scope 3rd field is a value see example "totalpolicypremium","pol0","1584" "quotenumber","pol0","5" "address1","pol0","123 Testing Street" "address2","pol0","" "apartmentnumber","pol0","" "cellphone","pol0","( ) -" ... "annualmiles","car1","0" "antilock","car1","A" "antitheft","car1","1" "bodytype","car1","4D" "buybackpip","car1","N" "carphone","car1","N" "city","car1","ALEXANDRIA" "coaccdeathlimit","car1","0" ... "annualmiles","car2","0" "antilock","car2","N" "antitheft","car2","1" "bodytype","car2","4D" "buybackpip","car2","N" "carphone","car2","N" "city","car2","ALEXANDRIA" ... "address1","drv1","123 Testing Street" "address2","drv1","" "agerated","drv1","0" "banklienjudgstat","drv1","N" "cellphone","drv1","( ) -" "city","drv1","Testing City" "cluestatus","drv1","N" etc The third party company sent me a file that contained all of their valid tagnames and scope which I then took and create a crossreference file with three fields: xreffile tagname (key) scopy SQL_fieldname The program I am writing is nothing more than a conversion program to take the value out of the CSV file and map it into the appropriate field in my SQL files. Rather than creating some huge if than else (there are over 1000 tagnames) I created the xreffile. Now when I read a record from the tagfile I use the data in the tagname field to lookup the tagname in my xreffile. The data in the SQL_fieldname is the fieldname in my SQL files I want to place the data from the tagfile in the tagfile.value field into this field in my SQL files; data referenced by(xreffile.SQL_fieldname) = tagfile.value what I see as the problem is I want to use what is the data reference by xreffile.SQL.fieldname and now make it part of the python code as a reference variable in an assignement code statement. I hope this helps Len Sumnler Unique Insurance [EMAIL PROTECTED] wrote: > Do you absolutely need to use variables? A dictionary would serve if > each case has a unique identifier. > > client_info_dict = {} > > for i in tagfile: > tagname,scope,value = i.replace('"','').split(',') # split fields, > strip redundant characters > client_info_dict.setdefault(scope,{}) # set up an empty nested > dict for the unique ID > client_info_dict[scope][tagname] = value # set the tagname's value > > Then client info can be retrieved from the dictionary using unique IDs > and stereotyped tags (with .get() if some tags are not always present). > I won't make any claims about the efficiency of this approach, but it > works for me. > > len wrote: > > Hi all > > > > I have a file that I receive from another party which is basicly a csv > > file containing the following type of information; > > > > Tagname Scope Value > > "first_name","POL01","John" > > "last_name","POL01","Doe" > > "birthday","POL01","04/03/61" > > etc > > > > I need to convert this file info into my file format used in my > > application. > > > > I have been given a file from the other company that gives me all of > > the tagname that could be used and their scope. I want to build a > > table which would have all of the various tagnames, scope, and put a > > fieldname equivalent in the fieldname in my file structure in my > > application. Then read through the vendors csv file index into my > > table file and get the field name of where to move the data into my > > data structure. > > > > Here is my question? basicly I need to get the data referenced by > > fieldname variable in my table and then use that data as a variable > > name in a python assignment statement. Thus changing the actual python > > code at each iteration through the lines in the csv file. > > > > for i in tagfile > > find tagname in tagtable > > > > *** the following line of code would change through each iteration *** > > myfirst = value > > > > *** next iteration > > mylast = value > > > > *** next iteration > > mybirth = value > > > > etc > > > > I hope this make sense. I remember seeing something like this > > somewhere. > > > > Any help appreciated. > > > > Len Sumnler > > Unique Insurance -- http://mail.python.org/mailman/listinfo/python-list