473,480 Members | 1,874 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

reading text files

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
Nov 20 '05 #1
3 3788
"Bre-x" <ch*******@hotmail.com> schrieb:
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.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #2
"Bre-x" <ch*******@hotmail.com> schrieb
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
--
Armin

Nov 20 '05 #3
Hi Bre-x,

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

Regards,
Fergus
Nov 20 '05 #4

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

Similar topics

2
2778
by: dunnm | last post by:
This is probably a more appropriate location to post this question. I should have know that since I've found most of the other PHP/PDF information contained in this group. Here's my issue...I...
19
10264
by: Lionel B | last post by:
Greetings, I need to read (unformatted text) from stdin up to EOF into a char buffer; of course I cannot allocate my buffer until I know how much text is available, and I do not know how much...
1
6736
by: Magnus | last post by:
allrite folks, got some questions here... 1) LAY-OUT OF REPORTS How is it possible to fundamentaly change the lay-out/form of a report in access? I dont really know it that "difficult", but...
50
4874
by: Michael Mair | last post by:
Cheerio, I would appreciate opinions on the following: Given the task to read a _complete_ text file into a string: What is the "best" way to do it? Handling the buffer is not the problem...
40
4455
by: googler | last post by:
I'm trying to read from an input text file and print it out. I can do this by reading each character, but I want to implement it in a more efficient way. So I thought my program should read one...
1
1932
by: Hutty | last post by:
I have a program that open text files and compares them, however, when reading files larger than 500kb the programs seems to bomb. I get re-directed to "page not found". Any idea how to get...
2
11635
by: Eshban Bahadur | last post by:
Hello, I want to read (RTF) files in my VB.NET programme. How can i do it. I apply the same method of reading text files, but it does not save the formatting of text like (bold, italics,...
6
5234
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
2
3206
by: Wes Peters | last post by:
Does anyone know of an article that deals with the subject of reading a structured text file using VBA code in Access? Thanks, Wes
7
3040
by: random guy | last post by:
Hi, I'm writing a program which creates an index of text files. For each file it processes, the program records the start and end positions (as returned by tellg()) of sections of interest,...
0
6908
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7048
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
6956
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4783
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4485
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2986
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
183
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.