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
Thanks In Advance.
2 3163
Normally all you need to do is read split up the data by line breaks, then by the comma. Heres a simple function that can do that: -
Public Function ReadCSV(ByVal data As String) As List(Of String())
-
Dim result As New List(Of String())
-
Dim lines As String() = data.Split(vbCrLf.ToString())
-
-
For Each line As String In lines
-
result.Add(line.Split(New Char() {","}, _
-
StringSplitOptions.RemoveEmptyEntries))
-
Next
-
-
Return result
-
End Function
-
And to use it: -
Dim data As String = "A0001,3,Y,13,LU, " & vbCrLf & _
-
"A0001,3,Y,13,CLARK P, " & vbCrLf & _
-
"A0001,3,Y,13,SMITH JOHN, " & vbCrLf & _
-
"A0001,3,Y,13,BEAL KRISS J, " & vbCrLf & _
-
"A0001,3,Y,13,THOMAS A CLIFF C, " & vbCrLf & _
-
"A0001,3,Y,13,DEW III ROBERT H, "
-
-
For Each row In ReadCSV(data)
-
ListBox1.Items.Add(row(4))
-
Next
-
Seems to me that you've been asked to fix broken data. If the firstname, lastname and middle initial were not entered in specific fields for their respective purposes - there is no clean way to retrieve it that way.
You will inevitably run into examples like
John Smith III
and
Smith John III
or
Smith III John
So unless you are going to read each entry and clean up the data - then you will likely wind up with some percentage of incorrectly mapped fields. If there's not a lot of data - fine, do it by hand. If there is, yikes.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Calan |
last post by:
I have a server-side ASP script that dynamically creates an input form from
a database table. The table contains a field name, the table where values
are stored, type of input control, value for a...
|
by: Gary |
last post by:
I have a backend Database with just one main table in it (no form/queries
etc)
The network pc's have the front end database (with all the forms,
queries,macros etc). These front ends are linked...
|
by: Joe Laughlin |
last post by:
If I have a character array with "/some/file/directory/file_name", are there
any functions / libraries that I could use to separate the directory
("some/file/directory") from the file name...
|
by: Joe Laughlin |
last post by:
I've not used C much before, so I don't know how robust or good this code
is. I'd appreciate any feedback or criticisms anyone has!
Thanks,
Joe
#include <stdio.h>
#include <string.h>
|
by: Prasanna Padmanabhan |
last post by:
I want to process requests to certain image files that have a custom
..icon(32x32) extenstion with a custom .NET HttpHandler in order to be able
to tap into Application events. This works fine...
|
by: Jeff S |
last post by:
Please note that this question is NOT about any particular pattern - but
about the general objective of separating out presentation logic from
everything else.
I'm trying to "get a grip" on some...
|
by: Luc Kumps |
last post by:
(Sorry about the previous post, it got transmitted before it was complete)
We try to separate implementation and interface defintions, but we run into
a problem. I hope the guru's can solve this,...
|
by: janetager |
last post by:
I have a field that has names in it in the format "last name, first
name". I want code that will split this field for me at the comma so I
can make 2 separate fields for last name and first name. ...
|
by: eduardoamfm |
last post by:
Hi everybody!
I have the following files: (MSC.080806.00, MSC.080806.01, MSC.080806.02...) each one has the same pattern, with two different START and STOP times and values:
...
...
|
by: Steven Simpson |
last post by:
Stefan Ram wrote (in "More than one language in a page"):
Is this a new trend of user-agent writers (Microformats, and now Google)
staking claims on the @class namespace? I'm surely not the only...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |