Need to read file containing delimiters

sivag

Member
Joined
Jul 10, 2007
Messages
15
Programming Experience
Beginner
hi all i need to read a file containing as follows

aaa*b*c*d*e
sdef*t*e*r*u*i


now i need to put them as
aaa sdef
b t
c e
d r
e u
i

I need to display aaa as one column & sdef as another column.the items "b,c,d,e" must be under aaa while remaining under sdef column in a grid.

I don't want to use database for this.Any idea for this? Thx in advance
 
Last edited:
Is this just a text file? If it is, then this should work, otherwise someone else can probably help you out with working with a database.
VB.NET:
Dim mystring1 as String = "aaa*b*c*d*e" ' Just given the two lines, this will show you the basic idea.
Dim mystring2 as String = "sdef*t*e*r*u*i"
Dim Split1() as String = mystring1.Split("*")
Dim Split2() as String = mystring2.Split("*")
Dim Grid as String = Split1(0) & " " & Split2(0)
...
I think you can see what this is doing. I just noticed that you mentioned a grid, and I'm not sure how to work with those. "Grid" can grab out the elements you need by index in the two strings that I created from splitting by delimiters.
 
thanks a lot

I understood what you said & have wrote like this

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fs As StreamReader
Dim readcontents As String
Dim filedelimiter As String
Dim i As Integer = 0

filetoread = Application.StartupPath & "\1.txt"

fs = File.OpenText(filetoread)
readcontents = fs.ReadToEnd()
filedelimiter = "*"
Dim sp = Split(readcontents, filedelimiter)
For i = 0 To UBound(sp)
RichTextBox1.Text &= sp(i)
Next
fs.Close()
End Sub

hope you came to know i am reading it from a file.Now i have put those in a rich textbox.but i need to display in a grid. this where i got stuck now.

thx again
 
The hard part is, youre transposing this data too (x/y axis swap)

Personally, I'd read it into a datatable, then pivot it..

http://www.google.co.uk/search?sour...s=GGLG,GGLG:2006-25,GGLG:en&q=pivot+Datatable


The Microsoft Jet driver can be used to read a text file with delimiters, so you would set up a schema.ini file to describe your text file,

http://msdn2.microsoft.com/en-us/library/ms709353.aspx


then make a connection to the file,

http://www.dotnet247.com/247reference/msgs/22/111793.aspx

then use a dataadapter to "SELECT * FROM #FILE"


-

Once upon a time, I wrote a library that would help with this, by turning your text file into xml on the fly, that could be read into a dataset. You can do this yourself too..
 
Back
Top