473,385 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Delimiter question

gn
I am trying to parse a txt file which looks something like example
below:

th*******@email.com
th*******@email.com
an**********@email.com

This is the code I am using:

filetoread = file1.Value
filestream = File.OpenText(filetoread)
readcontents = filestream.ReadToEnd()
textdelimiter = " "
Dim splitout = Split(readcontents, textdelimiter)
Dim i As Integer
For i = 0 To UBound(splitout)
lblsplittext.Text &= "<b>Split </b>" & i + 1 & ") " & splitout(i)
& "<br>"
Next

This works fine if the file is in the format:

th*******@email.com th*******@email.com an**********@email.com

But what delimiter should I use to indicate a new line as a delimiter?

Thank you in advance...

Mar 2 '06 #1
4 1125
You can use Environment.NewLine.

Mar 2 '06 #2
gn
Thank you,

But how would I use that in the above code?

Mar 2 '06 #3
I made a small function to test the my answer before I sent it. The
code is different (more DotNetish), but you are welcome to it =)

Import the following libraries at the top of your code:

Imports System.IO
Imports System.Text

Here was my method:

Dim FileName As String = "test.txt"
Dim FileContents As String
Dim sr As StreamReader

Try
sr = File.OpenText(FileName)
FileContents = sr.ReadToEnd()
Catch ex As Exception
MessageBox.Show("Unable top open file: " & ex.Message)
Return
Finally
If (sr Is Nothing) = False Then
sr.Close()
End If
End Try

Dim Lines() As String = Split(FileContents,
Environment.NewLine)
Dim Output As New StringBuilder
Dim i As Integer
For i = 0 To Lines.Length - 1
Output.Append("<b>Split </b>" & i + 1 & ") " & Lines(i) &
"<br />")
Next

lblSplitterText.Text = Output.ToString

Mar 2 '06 #4
gn
Thank you so much - Perfect!

Mar 2 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Laurent | last post by:
Hello, is it possible to read a file in python line by line by redefining a new end-of-line delimiter ? I would like for example to have the string "END" being the new delimiter for each...
1
by: Alan Zhong | last post by:
hi, i had been removed the row counts and the column spaces... but i failed to remove the extra tabs between rows of data return from the osql output. how to detect the row delimiter? i noticed...
7
by: Generic Usenet Account | last post by:
I am trying to set up a delimiter character string for the input stream such that the delimiter string is "skipped over" in the input stream. Can someone suggest how to do this with some sample...
4
by: Raquel | last post by:
Could someone explain to me what the reason is for having a character delimiter (which is double quotes by default) for performing Loads/Imports on UDB? I would think that column delimiter along...
9
by: _link98 | last post by:
Normally I use the semicolon for statement delimiters in plain SQL scripts (for DDL, simple DML etc.). But inside SQL/PL I tend to use % or @ as statement delimiters. But other people prefer...
3
by: magix | last post by:
Dear Guru, I have been thinking hard on how to token based on demiliter after certain position. Example, I have list of possible string below, and the the delimiter is "1" with the rules below...
2
by: pengb | last post by:
Hello All: A pretty frustrating question to ask! I use the string something = stringx.split (delimiter.tochararray()) mathod to delimit a long string by space! So supposely if the stringx is :...
4
by: kretik | last post by:
I've been trying to coax this class to use something other than the default '$' but it seems setting it to something else has no discernible effect. Is it necessary to inherit from the class to do...
11
by: Sven Reuter | last post by:
Hallo NG, ich versuche gerade ein PHP-Script zu bauen, das einen Trigger in einer MySQL-Datenbank erstellt. Doch leider funktioniert das nicht und ich habe auch über google keine Hinweise...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.