Wrox Home  
Search P2P Archive for: Go

  Return to Index  

activex_data_objects thread: Parsing a text file..


Message #1 by "Srinivasan Prasanna" <Sri_Core@m...> on Mon, 22 Apr 2002 11:25:52 -0400
------=_NextPart_001_0003_01C1E9F0.75D2B2D0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

 
 
I am writing an application which shall parse through a text file and gra
b these values and put in a table form as an output. The test file is lik
e this
9321--03139-134912-943JDOIASJOPJDFSA;Test12@m...;21-093-21943 DNSANDFS
AJDFOISJF;test15@m...
 
The output I require will be ID number (9321) SysID number (03139) CtrlID
 (943JDOIASJOPJDFSA) and the email ID (Test12@m...) .....

I would highly appreciate any help from anyone.
Thanks
SriGet more from the Web.  FREE MSN Explorer download : http://explorer.m
sn.com

Message #2 by Andy Faulkner <afaul@t...> on Mon, 22 Apr 2002 11:54:54 -0400
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C1EA16.0B9FB2C0
Content-Type: text/plain;
	charset="iso-8859-1"

if you are using VB...read the text file line by line.  then use the split
function to separate the record into an array. then write a querydef with an
insert statement inputting your fields.
 
andy..

-----Original Message-----
From: Srinivasan Prasanna [mailto:Sri_Core@m...]
Sent: Monday, April 22, 2002 11:26 AM
To: ActiveX_Data_Objects
Subject: [activex_data_objects] Parsing a text file..


 
  
I am writing an application which shall parse through a text file and grab
these values and put in a table form as an output. The test file is like
this
9321--03139-134912-943JDOIASJOPJDFSA;Test12@m...;21-093-21943
DNSANDFSAJDFOISJF;test15@m...
 
The output I require will be ID number (9321) SysID number (03139) CtrlID
(943JDOIASJOPJDFSA) and the email ID ( Test12@m...
<mailto:Test12@m...> ) .....

I would highly appreciate any help from anyone.
Thanks
Sri
--- 

  _____  

Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com
<http://explorer.msn.com> 





Message #3 by joe.dunn@c... on Wed, 24 Apr 2002 09:26:59 +0000
To parse:
9321--03139-134912-943JDOIASJOPJDFSA;Test12@m...;21-093-21943
DNSANDFSAJDFOISJF;test15@m...

into:
ID number (9321) SysID number (03139) CtrlID (943JDOIASJOPJDFSA) and the
email ID (Test12@m...)



Function ParseIDString(pString as string) as string

Dim strNew as string, strOld as string, intPos as Integer

strOld = pString

' store the first part of the string up to the hyphen
intPos = Instr(strOld,"-")
strNew = "ID number (" & left$(strOld,intPos - 1) & " SysID number ("
' trim off the bit we have used
strOld = Mid$(strOld, intPos + 1)
' we now have:
' 03139-134912-943JDOIASJOPJDFSA;Test12@m...;21-093-21943
' DNSANDFSAJDFOISJF;test15@m...

' store the second part of the string up to the hyphen
intPos = Instr(strOld,"-")
strNew = strNew & left$(strOld,intPos - 1) & " ) CtrlID ("
' trim off the bit we have used
strOld = Mid$(strOld, intPos + 1)
' we now have:
' 134912-943JDOIASJOPJDFSA;Test12@m...;21-093-21943
' DNSANDFSAJDFOISJF;test15@m...

' find and discard the third part of the string up to the hyphen
intPos = Instr(strOld,"-")
' trim off the bit we have used
strOld = Mid$(strOld, intPos + 1)
' we now have:
' 943JDOIASJOPJDFSA;Test12@m...;21-093-21943
DNSANDFSAJDFOISJF;test15@m...

' store the fourth part of the string up to the semi-colon
intPos = Instr(strOld,";")
strNew = strNew & left$(strOld,intPos - 1) & " ) and the email ID ("
' trim off the bit we have used
strOld = Mid$(strOld, intPos + 1)
' we now have:
' Test12@m...;21-093-21943 DNSANDFSAJDFOISJF;test15@m...
' store the fifth part of the string up to the semi-colon
intPos = Instr(strOld,";")
strNew = strNew & left$(strOld,intPos - 1) & " )"

' the string is now complete and can be returned to the calling process
ParseIDString = strNew

End Function


I have not tested this but it should work - I have assumed that the length
of each required element in your input string may vary but if it does not
the whole exercise is very simple - just use a series of Mid$ statements to
extract the elements.

Joe Dunn



*************************************************************************

This e-mail may contain confidential information or be privileged. It is intended to be read and used only by the named
recipient(s). If you are not the intended recipient(s) please notify us immediately so that we can make arrangements for its return:
you should not disclose the contents of this e-mail to any other person, or take any copies. Unless stated otherwise by an
authorised individual, nothing contained in this e-mail is intended to create binding legal obligations between us and opinions
expressed are those of the individual author.

The CIS marketing group, which is regulated for Investment Business by the Financial Services Authority, includes:
Co-operative Insurance Society Limited Registered in England number 3615R - for life assurance and pensions
CIS Unit Managers Limited Registered in England and Wales number 2369965  - for unit trusts and PEPs
CIS Policyholder Services Limited Registered in England and Wales number 3390839 - for ISAs and investment products bearing the CIS
name
Registered offices: Miller Street, Manchester M60 0AL   Telephone  0161-832-8686   Internet  http://www.cis.co.uk   E-mail
cis@c...

CIS Deposit and Instant Access Savings Accounts are held with The Co-operative Bank p.l.c., registered in England and Wales number
990937, P.O. Box 101, 1 Balloon Street, Manchester M60 4EP, and administered by CIS Policyholder Services Limited as agent of the
Bank.

CIS is a member of the General Insurance Standards Council

CIS & the CIS logo (R) Co-operative Insurance Society Limited

********************************************************************************

  Return to Index