Parse a Text File

athomas42

New member
Joined
May 30, 2007
Messages
4
Programming Experience
5-10
textfile content:
From: webmaster@###.com
Sent: Thursday, May 24, 2007 2:25 PM
To: Webmaster
Subject: ####.com Contact us email

####.COM Contact us email notification

Name:##### #####
Title:Recruiter
Company:##### ######
Address1:#### #### ####
Address2:
City:##### #####
State:######
Zip:#####
Phone:###-###-####
Fax:
Email:ljones@###.net
eNewsletter:No
Question/Comments:Hello my name is John Doe and I represent etc.

I need to take this file in the format that it is in and go line by line and parse the data and put it in a sql db. Any help will be appreciated
 
Last edited by a moderator:
textfile content:


I need to take this file in the format that it is in and go line by line and parse the data and put it in a sql db. Any help will be appreciated

I wrote a class that would do this.. using a set of carefully constructed regualr expressions, it can convert any text file, on the fly, into a dataset xml, which can be easily read in and sent to a database
 
Quote:

I wrote a class that would do this.. using a set of carefully constructed regualr expressions, it can convert any text file, on the fly, into a dataset xml, which can be easily read in and sent to a database


Do you have an example of it
 
athomas,

I hope you know how to read the text file by now... if not, please visit my blog page... there's one or two blog dealing with text file.

As for parsing the data, here's a little code fragment:

VB.NET:
Dim sSample as string = "Name: value"
Dim sValue as string
sValue = mid(sSample, instr(sSample, ":", comparemethod.text ))
[code]

Make sure you use intellisense to check the code as i wrote it off the top of my head.
 
Back
Top