0

I am trying to rearrange the columns of below file

input.txt,

Contents of this file:

Name      Location      Purpose
---------------------------------------------
Andy      US            Business1
bob       UK            Business2

output_obtained

Name      Purpose       Location
---------------------------------------------
Andy      Business1     US
bob                     Business2     UK

Expected_output

Name      Purpose       Location
---------------------------------------------
Andy      Business1     US
bob       Business2     UK

TCL file:

set fh [open input.txt r]
set fp [open output.txt w]
while {[gets $fh line]>=0} {
if {[regexp "^-" $line]} {
puts $fp $lin
} else {
puts $fp "[lindex $line 0]\t[lindex $line 2]\t[lindex $line 1]"
}
}
close $fh
close $fp

I cannot understand why the tab is interpreted differently on the last row

  • 1
    What does this have to do with Emacs? – Stefan Jan 23 at 16:35
  • I posted it on the wrong forum. Not sure how do I delete this questions from here – user26663 Jan 23 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy