SORRY I THINK I ADDED THIS TO SOMEONE ESLE THREAD B4
Ok so i have a file which i read in ... then i read the data line by line and create lists

basically i needed to organsise(sort the data, in numerical order which i can do no problem and when i do the print statement it all works... no how can i write this sorted data into a new file?

when i do i get loads of lines into my new with the final line having all my data in the sorted order??? its because i need to carry out further functions on the sorted data ..

any suggestions????

i can mail my codes if anyone can help( im trying to so the excel sort function to my data if that makes sense?)

thanks xx

You post makes no sense to me!

sorry ok basically i have an open a file and i have read the lines


my file looks like this


4 267 156 0.999 0.1 1
1 236 2366 0.999 0.1 1
1 235 2365 0.999 0.1 1..... and so on

so i wish the data to be sorted in order which i have done and when i print it it looks as follow
1 235 2365 0.999 0.1 1.
1 236 2366 0.999 0.1 1
4 267 156 0.999 0.1 1.........

i did this using the sort function and did print sort_output
however when i try to write sort_outpt i get the following in a new file

[4 267 156 0.999 0.1 1]
[1 236 2366 0.999 0.1 1],[4 267 156 0.999 0.1 1]
[1 235 2365 0.999 0.1 1],[1 236 2366 0.999 0.1 1],[4 267 156 0.999 0.1 1].....

and so on until the last line is my fully sorted data... what am i doing wrong?

i would just like one line to be writen to my new output file

just this one? [1 235 2365 0.999 0.1 1],[1 236 2366 0.999 0.1 1],[4 267 156 0.999 0.1 1]....(more list in numerical order)
can someone please help

uuffff i feel so silly i just need to put in a for loop... problem and drama over with

and so on until the last line is my fully sorted data

No way to tell without any code. For example, what is "sort_ouput"? It appears to be a function, but then it would be "sort_output()". It also appears that you are printing the record and then adding it to the existing records, then writing the corrupted data to a file. You can either write at the same spot you print, and use the same data, or post some code so someone can help with it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.