views:

46

answers:

2
+1  Q: 

separating names

Im trying to Separate Last name, First Name and Middle Initial. File is csv format, here is an example:

A0001,3,Y,13,LU,
A0001,3,Y,13,CLARK P,
A0001,3,Y,13,SMITH JOHN,
A0001,3,Y,13,BEAL KRISS J,
A0001,3,Y,13,THOMAS A CLIFF C,
A0001,3,Y,13,DEW III ROBERT H,

Output fields : 
                Last name               First name           Initial   
                  LU                    
                  CLARK                   P 
                  SMITH                   JOHN 
                  BEAL                    KRISS                J 
                  THOMAS A                CLIFF                C 
                  DEW III                 ROBERT               H

I hope someone can help with VB script maybe? Thanks in advance.

A: 

Use Split() on each line. That will give you an array, split on a delimiter... in this case, a comma.

http://msdn.microsoft.com/en-us/library/6x627e5f(VS.80).aspx

Brad
+1  A: 
  • First split on coma and get the name part seperated.
  • Now on the name part, split using space and take
  • the last element as last name
  • second last element as middle name
  • and the rest as first name.

Hope this helps,
Happy Programming...

Vimal Raj
This is good, but it looks like the first element is the last name instead of the last element.
Dennis Palmer
@Dennis, you are right, I missed that. oops...
Vimal Raj
Oh, and it might be the first 2 elements as the last name. It is a tricky problem.
Dennis Palmer