?
Solved

parsing file

Posted on 2004-11-04
3
Medium Priority
?
227 Views
Last Modified: 2010-04-23
I have a file that looks like
 ISA*3495*00*  *00* 68393*78*~GS*5930*MANNOR*45*56~
I want to use two splits to seperate the segment and the element seperators so that my file looks like this
ISA 3495 00   00 68393
GS 5930 MANNOR 45 56

On two seperate lines like this.  Can anyone give me an example of how to write this code?

Thanks
0
Comment
Question by:lindapat
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
arif_eqbal earned 1500 total points
ID: 12501439
You must be Reading the file line by line
So lets assume you have one line in a variable StrLine

then

StrLine=StrLine.Replace("*"," ")
'It seems in the result that you want there's a space for * but only two spaces between 00 and 00, that means the original space is lost better use

StrLine=StrLine.Replace(" ","") 'Remove all spaces
StrLine=StrLine.Replace("*"," ")'Convert * to spaces

'Then

Dim StrArr() as String
StrArr=StrLine.Split("~")

'Now StrArr contains all the Lines

The complete code will look like


Dim StrLine As String = "ISA*3495*00*  *00* 68393*78*~GS*5930*MANNOR*45*56~"
'Read from File in the above line
        Dim StrArr() As String
        Dim i As Integer
        StrLine = StrLine.Replace(" ", "") 'Remove all spaces
        StrLine = StrLine.Replace("*", " ") 'Convert * to spaces
        StrArr = StrLine.Split("~")
        For i = 0 To UBound(StrArr)
            MsgBox(StrArr(i)) 'You'd probably like to store it in a new file??
        Next


0
 

Author Comment

by:lindapat
ID: 12565947
thank you very much
0
 

Author Comment

by:lindapat
ID: 12565981
Thank you  very much.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Integration Management Part 2
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question