Writting to specific location in a file

A

artixan

I have a database result set in a Python list. Each row is a tuple.
data = [(a_field,b_field,c_field,d_field,x_field,y_field,z_field)]

I need to loop thru this data and write each row to a text file.

f = open('out.txt','w')
for row in data:
f.writelines(row)


My chanllenge is that each field needs to have a exact specific
position in the output file.
For instance a_field needs to start at position 2 in the line, b_fields
at position 18 and so on, for all the fields on each line.


What is a way of approaching this problem. I was think of maybe
creating a Cheetah template file. Is there a simple way to go?

Can anyone point me to a possible way of doing this?


Thanks a lot,

Arnaldo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,221
Messages
2,571,130
Members
47,747
Latest member
swapote

Latest Threads

Top