reading text files

  • Thread starter Thread starter Bre-x
  • Start date Start date
B

Bre-x

Hi,

I have a text file that is made of a number of paragraphs:

each paragraph start with either: ":O", ":N", or ":" follow by a 4
digit number and finish with either: M30 or M99

What I need to do is go down the file and capture the text between and
create a new text file for each occurrence using the name of the
original file plus the first line less the ":"

Orginal file: 625.txt

:1041
text here
text here
text there
M30
:2393
text here
text here
text there
text here
text hereM30
:N2112
text here
text here
M99

the end result will be: 3 files 6251041.txt, 6252393.txt and
6252112.txt

I hope you guys can help me

Regards,

Bre-x
 
Bre-x said:
Hi,

I have a text file that is made of a number of paragraphs:

each paragraph start with either: ":O", ":N", or ":" follow by a 4
digit number and finish with either: M30 or M99

What I need to do is go down the file and capture the text between
and create a new text file for each occurrence using the name of
the original file plus the first line less the ":"

Orginal file: 625.txt

:1041
text here
text here
text there
M30
:2393
text here
text here
text there
text here
text hereM30
:N2112
text here
text here
M99

the end result will be: 3 files 6251041.txt, 6252393.txt and
6252112.txt

I hope you guys can help me

Did you already have a look at the System.IO namespace?

See also:

Visual Studio.NET
.NET Framework
Programming with .NET Framework
-> Working with I/O
Visual Basic and Visual C#
Reference
Visual Basic language
Visual Basic Language Tour
-> Processing drives, folders and files
 
Bre-x said:
I have a text file that is made of a number of paragraphs:

each paragraph start with either: ":O", ":N", or ":" follow by a 4
digit number and finish with either: M30 or M99

What I need to do is go down the file and capture the text
between and create a new text file for each occurrence using
the name of the original file plus the first line less the ":"

Basic code for reading the lines of a file:

\\\
Imports System.IO
..
..
..
Dim sr As New StreamReader("C:\WINDOWS\WIN.INI")
Dim strLine As String
strLine = sr.ReadLine()
Do Until strLine Is Nothing
MsgBox(strLine)
strLine = sr.ReadLine()
Loop
sr.Close()
///

Have a look at the 'StreamWriter' class. This class can be used to write
data to a file.
 
Hi Bre-x,

If you're still having difficulty after reading the references given, come back and add to thi thread.

Regards,
Fergus
 
Back
Top