473,407 Members | 2,306 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,407 software developers and data experts.

Read Text File and split them to individual text file

I have requirement, that i get one big chunk of text file. This text file
will have has information, that on finding "****End of Information****", i
have to split them individual text file with our naming standard (unique id)
and create them designated folder.

This requirement should be created as a batch job and preferrably this job
should monitor the folder where one big chunk of text file lands and process
them immediately.

\\Textfile\IN folder => one big chunk text file comes here by different
source

\\Textfile\Output\yyyyddmm folder => i need to process (split) the text file
coming "IN" folder to different text files based on "End of Information"
delimiter.

I need to achieve this using dot net preferrably using Csharp. Pl. note that
i have recently started learning cSharp but has almost 6 years experience of
using Visual Basic & COM + etc.

Pl. throw any thoughts that you may want to share.

To tell you how the text file will look
unique ID : 999
Text blah blah blah blah......
something here..
some information ...
"****End of Information****"
unique ID : 999
Text blah blah blah blah......
something here..
some information ...
"****End of Information****"
unique ID : 999
Text blah blah blah blah......
something here..
some information ...
"****End of Information****"

Thanks,
Krish
Nov 17 '05 #1
3 8539
Krish,

First, you will need to use the FileSystemWatcher class. You can
specify the directory of your input files to watch, and be notified when a
new file is created there.

Once you do this, you can use the FileStream class to open a stream for
reading, as well as for new streams to write your new files.

You can also use the StreamReader class to wrap the FileStream reader.
This will allow you to read lines (assuming that your delimiter takes a line
to itself). You can also use the StreamWriter class to make writing the
strings to the new file easy.

Then, you can use the static CreateDirectory method on the Directory
class to create your new directory to output your files.

All of these classes are in the System.IO namespace.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Krish" <vi***************@GMAIL.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
I have requirement, that i get one big chunk of text file. This text file
will have has information, that on finding "****End of Information****", i
have to split them individual text file with our naming standard (unique
id) and create them designated folder.

This requirement should be created as a batch job and preferrably this job
should monitor the folder where one big chunk of text file lands and
process them immediately.

\\Textfile\IN folder => one big chunk text file comes here by different
source

\\Textfile\Output\yyyyddmm folder => i need to process (split) the text
file coming "IN" folder to different text files based on "End of
Information" delimiter.

I need to achieve this using dot net preferrably using Csharp. Pl. note
that i have recently started learning cSharp but has almost 6 years
experience of using Visual Basic & COM + etc.

Pl. throw any thoughts that you may want to share.

To tell you how the text file will look
unique ID : 999
Text blah blah blah blah......
something here..
some information ...
"****End of Information****"
unique ID : 999
Text blah blah blah blah......
something here..
some information ...
"****End of Information****"
unique ID : 999
Text blah blah blah blah......
something here..
some information ...
"****End of Information****"

Thanks,
Krish

Nov 17 '05 #2
Excellent. The points you have mentioned will give me good start.

Krish

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP15.phx.gbl...
Krish,

First, you will need to use the FileSystemWatcher class. You can
specify the directory of your input files to watch, and be notified when a
new file is created there.

Once you do this, you can use the FileStream class to open a stream for
reading, as well as for new streams to write your new files.

You can also use the StreamReader class to wrap the FileStream reader.
This will allow you to read lines (assuming that your delimiter takes a
line to itself). You can also use the StreamWriter class to make writing
the strings to the new file easy.

Then, you can use the static CreateDirectory method on the Directory
class to create your new directory to output your files.

All of these classes are in the System.IO namespace.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Krish" <vi***************@GMAIL.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
I have requirement, that i get one big chunk of text file. This text file
will have has information, that on finding "****End of Information****", i
have to split them individual text file with our naming standard (unique
id) and create them designated folder.

This requirement should be created as a batch job and preferrably this
job should monitor the folder where one big chunk of text file lands and
process them immediately.

\\Textfile\IN folder => one big chunk text file comes here by different
source

\\Textfile\Output\yyyyddmm folder => i need to process (split) the text
file coming "IN" folder to different text files based on "End of
Information" delimiter.

I need to achieve this using dot net preferrably using Csharp. Pl. note
that i have recently started learning cSharp but has almost 6 years
experience of using Visual Basic & COM + etc.

Pl. throw any thoughts that you may want to share.

To tell you how the text file will look
unique ID : 999
Text blah blah blah blah......
something here..
some information ...
"****End of Information****"
unique ID : 999
Text blah blah blah blah......
something here..
some information ...
"****End of Information****"
unique ID : 999
Text blah blah blah blah......
something here..
some information ...
"****End of Information****"

Thanks,
Krish


Nov 17 '05 #3
test
"Krish" <vi***************@GMAIL.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
I have requirement, that i get one big chunk of text file. This text file
will have has information, that on finding "****End of Information****", i
have to split them individual text file with our naming standard (unique
id) and create them designated folder.

This requirement should be created as a batch job and preferrably this job
should monitor the folder where one big chunk of text file lands and
process them immediately.

\\Textfile\IN folder => one big chunk text file comes here by different
source

\\Textfile\Output\yyyyddmm folder => i need to process (split) the text
file coming "IN" folder to different text files based on "End of
Information" delimiter.

I need to achieve this using dot net preferrably using Csharp. Pl. note
that i have recently started learning cSharp but has almost 6 years
experience of using Visual Basic & COM + etc.

Pl. throw any thoughts that you may want to share.

To tell you how the text file will look
unique ID : 999
Text blah blah blah blah......
something here..
some information ...
"****End of Information****"
unique ID : 999
Text blah blah blah blah......
something here..
some information ...
"****End of Information****"
unique ID : 999
Text blah blah blah blah......
something here..
some information ...
"****End of Information****"

Thanks,
Krish

Nov 17 '05 #4

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

Similar topics

6
by: Ruben | last post by:
Hello. I am trying to read a small text file using the readline statement. I can only read the first 2 records from the file. It stops at the blank lines or at lines with only spaces. I have a...
2
by: Mark Fisher | last post by:
Hi I have a database on a website, and a table in this db contains two fields, PCode, and Verified. I have to add new records to this in batches, and these batches are generated on a local PC....
1
by: Krish | last post by:
I have requirement, that i get one big chunk of text file. This text file will have has information, that on finding "****End of Information****", i have to split them individual text file with our...
5
by: Just Me | last post by:
Using streams how do I write and then read a set of variables? For example, suppose I want to write into a text file: string1,string2,string3 Then read them later. Suppose I want to write...
3
by: Ben | last post by:
Hi I am creating a dynamic function to return a two dimensional array from a delimeted string. The delimited string is like: field1...field2...field3... field1...field2...field3......
4
by: Karl | last post by:
How do you read a tab delimited text file? The file has 3 colums of data. I can read fixed width text files using the left and mid functions. I had rather not use transfer text and import specs.
24
by: garyusenet | last post by:
I'm working on a data file and can't find any common delimmiters in the file to indicate the end of one row of data and the start of the next. Rows are not on individual lines but run accross...
11
by: Eran.Yasso | last post by:
Hi All, I searched the web to see how i can read csv file (specific cells) but didn't find much. Can anyone give me a link or help how to read or write to a specific cell in csv file? Using...
5
by: dm3281 | last post by:
Hello, I have a text report from a mainframe that I need to parse. The report has about a 2580 byte header that contains binary information (garbage for the most part); although there are a...
7
by: antar2 | last post by:
Hello, I can not find out how to read a file into a list of lists. I know how to split a text into a list sentences = line.split(\n) following text for example should be considered as a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.