Tab delimited file

2006-08-11 Thread Colin Wildsmith








Hello,

I am making a gui for the purpose that I can change the
values in a list of different criteria which is found in a text file, such as:

 

Name(tab)rating(tab)breast size(tab)occurrences

…

…

…

 

However as far as I know Python does not allow you to easily
change a specific line in a text file. You have to place the whole file to
memory, change what you need to and then write the file back after deleting the
previous information. 

 

Assuming this is true, how do i find where the tabs are in
the file so that I can distinguish between the different criteria? 

Assuming this is not true, does anyone suggest another way
to do it?

 

CoLe

 






-- 
http://mail.python.org/mailman/listinfo/python-list

permanent tempfile?

2006-08-21 Thread Colin Wildsmith
Hello,
I am trying to create a temp file, however the file that is created
is still there after the program has completed.
Why is this so?

CoLe

#!/usr/bin/python

import os, tempfile, sys

import tempfile

# creates a random file (text=True is textfile, text=False is binary
file)
ext = '.txt'
pfx = 'tmp'
dir = '/home/argon/PR0001/source/emc2/bin'
filename = tempfile.mkstemp(suffix=ext, prefix=pfx, dir=dir,
text=True)[1]
print filename  # eg. C:\Temp\tmpsnrfgk.txt

# test it ...
fout = open(filename, 'w')
fout.write("just a text file")
fout.close()
os.remove(filename)


-- 
http://mail.python.org/mailman/listinfo/python-list