I don't get why this doesn't work. Its a very small program to read in a group 
of numbers. I've attached the the python file and my test file. The test file 
just contains one line. The error I get is that it can't convert the string to 
a float, but its a valid number.
# Test for string conversion

import string,sys

def convert_pts(filename):
	
	# Read in data using this bit
	fin=open(filename, 'r')
	i=0
	x = []; y = []; z = [];
	
	lines = fin.readlines()

	for line in lines:
		# comments indicated by #
		if line[0] != '#':
			i=i+1
			data = string.split(line)
			x.append(float(data[0]))
			y.append(float(data[1]))
			z.append(float(data[2]))

			n_lines = int(i)

	fin.close
	
def main():
  inputfile = sys.argv[1]
  convert_pts(inputfile)

if __name__ == "__main__":
    main()

Attachment: test.dat
Description: Netscape Proxy Auto Config

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to