Hi,

i have a list that contains 5 columns that contains strings and float values(3 strings columns and 2 float columns) ..

i want to export this list to a space separated text file (each column in the list is a column in the text file)

i tried to do this:

text_file = open("output/resfile.txt", "w")
for fw in len(range(list)):
    text_file.write(list[fw][0] + " " + list[fw][1] + "\n")

but it's not working,

how can i do the export easily in python??

thank you ..

Convert your float values into a String using the str() function and then try to write it. This is because the write() only takes string arguments.

is there any better way to do this ??

This is the easiest way I can think of. I mean its just surrounding str( ) around the 2 float elements while in the write().

ok, and how to separate columns by spaces??

This is just a small example.

my_list=[13.34,12.25,11.23]
file=open("myfile",'w');
for li in my_list:
    file.write(str(li)+" "+"my other values" )

Is it unclear?

yes, it worked now, thank you very much

Happy to help :). Please mark this post as solved.. If your question's completely answered.