semi-Newbie question

len lsumnler at gmail.com
Fri Aug 11 00:00:55 EDT 2006


Thank all for your reply.

I will try again to state the problem.

I have three files.

1.  Tagfile - This file contains data in a CSV format each record in
the file contains three fields 'Tagname', 'Scope', and 'Value' and
exampe of this data file follows;
"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

I have already written the code that can pass through this file using
the CSV module and extract the data as I need it from this file, no
problem here.

2.  TagToSQL - This is a file which I created which also contains 3
fields as follows
'theirTagname', 'theirScope', and 'mySQLfieldname'  and acts as a
crossreference file between the Tagfile and my SQL file example of
TagToSQL this file has a primary index on theirTagname;

"address1","POL1","bnd.addr1"
"address2","POL1","bnd.addr2"
"appartmentnumber","POL1","bnd.apptno"

etc
 3.  Binder - This is the primary Policy header file and is in MySQL
this file contains information such as;
bnd.policyno
bnd.last
bnd.first
bnd.addr1
bnd.addr2
bnd.city
bnd.state

etc

Now most of my coding experience is in compiled languages such as
cobol, c, assembler etc

I have all of the file access code completed as far as reading through
the CSV file and indexing into my TagToSQL file and writing to my SQL
files the only problem I have is how to create what I believe to be the
couple of lines of code which would allow me to move the date in
'Value' from the Tagfile into my SQL file using the data in the
TagToSQL field mySQLfieldname.

I have done some more reading and I think the code I need is as
follows;

mycode = "TagToSQL['mySQLfieldname'] = Tagfile['Value']"
exec mycode

This is very new to me because I don't believe this can be done in a
compiled language or at least not as easily as in an interpeted
language like Python.

I hope this clarifies the problem

Len Sumnler
Unique Insurance

Cameron Laird wrote:
> In article <1155245290.532108.75560 at 75g2000cwc.googlegroups.com>,
> len <lsumnler at gmail.com> wrote:
> >I appoligize I don't think I have done a very good job of explaining my
> >problem.
> 			.
> 			.
> 			.
> >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.
> 			.
> 			.
> 			.
> 1.  Take Daniel Wong's advice, elsewhere in this thread,
>     and use the Python CSV module.
> 2.  "what I see as the problem is I want ...":  what you
>     want *is* rather a problem, because it's a troublesome
>     way to achieve what I understand to be your larger
>     aims.  It was certainly good that you didn't create
>     "some huge if than else".
>
>     Once you have an SQL_fieldname, and a tagfile.value,
>     what do you want to do?  Are you stuffing data into
>     an SQL table?  Continuing on with Python computations?
>     In almost any case, it sounds as though you will profit
>     greatly from study of Python's dictionaries <URL:
>     http://www.developer.com/lang/other/article.php/630721 >
>     <URL: http://www.diveintopython.org/getting_to_know_python/dictionaries.html >.




More information about the Python-list mailing list