Link to home
Start Free TrialLog in
Avatar of mikensu12
mikensu12

asked on

cvs and space

Got a file that I want to separate and put in columns.  Look

Open in new window

like some of the fields in file are separated by spaces and other by tabs.  I want to format so the the name and address and etc are separated in columns.

strStarter = "RT 29	MONTPELIER VA 23100		23100"

intStarter = Len(strStarter)
For i = intStarter to 2 Step -1
    strChars = Space(i)
    strStarter = Replace(strStarter, strChars, " ")
	 strStarter1 = Replace(strStarter, vbTab,  " " )
Next

arrStarter = Split(strStarter, " ")
arrStarter2= Split(strStarter1,vbTab)

For Each strUnit in arrStarter
    Wscript.Echo strUnit
Next


For Each strUnit2 in arrStarter2
    Wscript.Echo strUnit2
Next

Open in new window

Test-Data.txt
Avatar of TalShyar
TalShyar
Flag of United States of America image

Assuming that you have access to MS Excel

1. Open MS Excel
2. Click on File | Open and point to the txt file
3. Select "delimited" on page 1 and hit Next
4. Select "TAB" and "SPACE" and hit Next
5. Set page 3 as default or change as needed
6. Hit finish and you are done.

Hell a lot faster than scripting it. If you need it in a script, let me which type and what language.
Avatar of Bill Prew
Bill Prew

What do you want the output to look like, maybe this?

RT 29,MONTPELIER VA 23100,23100
RT 50,MONTPELIER VA 23100,23100
DOE JOHN,2100 BOODROW AVE,RICHMOND VA 21000,23222

Open in new window

~bp
Avatar of mikensu12

ASKER

TalShyar,

This has to be automated


billprew,  the output below


DOE JOHN,RT 29,MONTPELIER VA 23100,23100
                 RT 50,MONTPELIER VA 23100,23100
                 2100 BOODROW AVE,RICHMOND VA 21000,23222
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I've requested that this question be closed as follows:

Accepted answer: 0 points for mikensu12's comment #a39346694

for the following reason:

good