hi
I have a file with columns delimited by '~' like this:
1SOME STRING ~ABC~1231123243 2D~20060401~000 00000
2SOME STRING ~DEF~1353453454 3C~20060401~000 00000
3SOME STRING ~ACD~1435345355 4G~20060401~000 00000
......
What is the pythonic way to sort this type of structured text file?
Say i want to sort by 2nd column , ie ABC, ACD,DEF ? so that it becomes
1SOME STRING ~ABC~1231123243 2D~20060401~000 00000
3SOME STRING ~ACD~1435345355 4G~20060401~000 00000
2SOME STRING ~DEF~1353453454 3C~20060401~000 00000
?
I know for a start, that i have to split on '~', then append all the
second columns into a list, then sort the list using sort(), but i am
stuck with how to get the rest of the corresponding columns after the
sort....
thanks...
I have a file with columns delimited by '~' like this:
1SOME STRING ~ABC~1231123243 2D~20060401~000 00000
2SOME STRING ~DEF~1353453454 3C~20060401~000 00000
3SOME STRING ~ACD~1435345355 4G~20060401~000 00000
......
What is the pythonic way to sort this type of structured text file?
Say i want to sort by 2nd column , ie ABC, ACD,DEF ? so that it becomes
1SOME STRING ~ABC~1231123243 2D~20060401~000 00000
3SOME STRING ~ACD~1435345355 4G~20060401~000 00000
2SOME STRING ~DEF~1353453454 3C~20060401~000 00000
?
I know for a start, that i have to split on '~', then append all the
second columns into a list, then sort the list using sort(), but i am
stuck with how to get the rest of the corresponding columns after the
sort....
thanks...
Comment