Is column 10 always empty?
Main Topics
Browse All TopicsI have a text file with 23 pipe delimited columns to it. I need to do the following to it:
1-Eliminate columns 1, 3, 4, 7, 8, 9, 11
2-Then of remaining columns, move column 4 to column 2 thus moving 2 to 3 and 3 to 4.
3-Then concatenating columns 2 and 3 with a underscore.
4-Changing file from pipe delimited to tab delimited file
5-Removing all double quotes from file
I've attache a txt file that takes it through the steps from start to finish so you can see what I want to end up with
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
OK. It's just in DOS the FOR command treats 2 delimiters together as 1. So if it is always empty give this a try. It was simple until the double delimiter. Hopefully you don't have any other rows that have blank columns.
I'm not sure if the tabs will copy properly from the attach code so I'm also attaching my file.
OK, here is the solution in VB6 code, but the logic can be used in other macros etc.
You call this prgram from the command line as :"ChangeFile <FileName>"
(e.g. "ChangeFile file-example.txt")
I ran the code against the single line example file you supplied.
I have included message boxes to show the progressive results, but if you are using the code to run in production, just remove all the message boxes starting with "Step"
WARNING! This code overwrites the original file being processed! If you want to retain the original file, please advise and I will tweak the code to allow for that.
Please also note speacial warning in the main() subroutine. You will need to alter the file name in the code line for testing. I used "C:\file-example.txt"
Is this what you are after?
Blimey! It appears there's a ferocious battle going on here...
I was bemused by the opening comment that a solution is just 'around the corner' and then, after several solutions were posted written in DOS, the VB solution eventually emerged and it was hilariously long, I actually physically laughed out loud.
I could scarcely believe that something accomplishable using just a few primitive DOS commands required such a huge effort from a versatile high-level and modern programming language.
I'm tryuly bewildered.
I have it on good authority the whole thing can be accomplished using just a single line of code written in Perl - Wow!
Well done to AmazingTech though.... I've only recently discovered that parsing CSV fiiles using just DOS commands can be quite challenging.
Hi,
The original solution is no longer working. Basically when there are more lines it just gives me one line in my output. Not sure what happned. The line it gives me is only the very last line thats in the source file. I changed the >> to > on the output part. So somehow each time it's just replacing the output instead of looping through each line? So the trick is to replace the file each time but at same time get all the lines.....Here is my code:
Set File=cfm_extract.txt
Set Output=2008_Budget_Final.t
for /f "tokens=2,5,6,10,11-22 delims=|" %%a in (%file%) do (
echo %%~a %%~d_%%~b %%~c %%~e %%~f %%~g %%~h %%~i %%~j %%~k %%~l %%~m %%~n %%~o %%~p>"%Output%"
)
Business Accounts
Answer for Membership
by: craisinPosted on 2009-09-11 at 09:24:01ID: 25311064
Am working on it...solution just around the corner