View previous topic :: View next topic
|
Author |
Message |
chintu687
New User
Joined: 06 Aug 2009 Posts: 7 Location: Hyderabad
|
|
|
|
Hi,
Can any one please suggest what is the command used for deleting required columns in a flat file. EX: A flat file with the length of 80 and i want to change the columns from 5-10 to 70-80. (or) i want to delet the columns 5-10. Thanks for your time.
Thank you,
chintu |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
There is no command to interchange columns and if you want to delete columns 5-10, you might be able to use
Code: |
c p'======' '' 5 all' |
but if the following columns contain spaces, that's likely to screw up. |
|
Back to top |
|
|
chintu687
New User
Joined: 06 Aug 2009 Posts: 7 Location: Hyderabad
|
|
|
|
Robert, the command is not working. |
|
Back to top |
|
|
donevin
New User
Joined: 07 Jun 2005 Posts: 70 Location: South Africa
|
|
|
|
To delete columns 5 to 10 I would go about it this way. First turn columns on with the cols command. Then turn boundaries on by entering BNDS on the first line. Then put a less than "<" sign on column 4 and a greater than sign ">" in column 80. Then to test put "(6" on the data line. This should move all data left 6 characters but keep the first 4 characters. If your happy with the result enter the block shift commands "((6" on first line and "((" on last line. Save if you're happy. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
chintu687 wrote: |
Robert, the command is not working. |
Which command? I want money! or Do this for me! |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Suggest you show us the "input" and expected "output" from that. |
|
Back to top |
|
|
chintu687
New User
Joined: 06 Aug 2009 Posts: 7 Location: Hyderabad
|
|
|
|
Thanks...
The solution works fine...
To delete columns 5 to 10 I would go about it this way. First turn columns on with the cols command. Then turn boundaries on by entering BNDS on the first line. Then put a less than "<" sign on column 4 and a greater than sign ">" in column 80. Then to test put "(6" on the data line. This should move all data left 6 characters but keep the first 4 characters. If your happy with the result enter the block shift commands "((6" on first line and "((" on last line. Save if you're happy. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
I'm still bemused as to why prino's solution didn't work. It's something I use a lot of the time
Wierd .................. |
|
Back to top |
|
|
donevin
New User
Joined: 07 Jun 2005 Posts: 70 Location: South Africa
|
|
|
|
It's a pleasure. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
May be he had "spaces" in those columns. |
|
Back to top |
|
|
chintu687
New User
Joined: 06 Aug 2009 Posts: 7 Location: Hyderabad
|
|
|
|
Donevin,
The below command is also working fine..
C ALL p'¬' '' 5 10 --> it deletes the columns from 5 to 10.
But my question ,is there any difference b/w the way you suggested and the above command?
Thank you,
chintu687 |
|
Back to top |
|
|
donevin
New User
Joined: 07 Jun 2005 Posts: 70 Location: South Africa
|
|
|
|
I don't see any difference except that my way is much longer than what you posted. So I'd use the shorter solution. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
typical missuse of words.
to delete columns means to shift data left or right.
to chg the values of data contained between columns is a much different thing. |
|
Back to top |
|
|
donevin
New User
Joined: 07 Jun 2005 Posts: 70 Location: South Africa
|
|
|
|
Yeah Dick, that's how I interpreted the post (to shift the columns) but the other command (C ALL p'¬' '' 5 10) yields the same results. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Agree with Dick -- that's why I asked show us the "input" and expected "output" from that.
There is other thread which asks to remove "," and when data gets shifted to left -- a set of good arguments follows... |
|
Back to top |
|
|
|