473,545 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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\Outp ut\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 8551
Krish,

First, you will need to use the FileSystemWatch er 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.co m

"Krish" <vi************ ***@GMAIL.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.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\Outp ut\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.c om> wrote in
message news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Krish,

First, you will need to use the FileSystemWatch er 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.co m

"Krish" <vi************ ***@GMAIL.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.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\Outp ut\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******** ********@TK2MSF TNGP14.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\Outp ut\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
4263
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 while statement checking for an empty string "" which I understand represents an EOF in Python. The text file has some blank lines with spaces and...
2
3093
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. Is it possible to paste the contents of a text file into a text area form field, and then run an asp/vbscript routine to update the database. ...
1
1683
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 naming standard (unique id) and create them designated folder. This requirement should be created as a batch job and preferrably this job should...
5
2245
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 and then read: string1, integer1, double1
3
9648
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... field1...field2...field3...
4
8312
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
4812
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 multiple lines. It would appear though that every distinct set of data starts with a 'code' that is always the 25 characters long. The text is variable...
11
3763
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 SQL can be great. TIA.
5
11226
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 couple areas that have ASCII text that I need to extract. At the end of the 2580 bytes, I can read the report like a standard text file. It should have...
7
9103
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 list of lists (3 columns and 3 rows), so that when I make the print statement list , that the word pear appears
0
7486
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7416
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
6001
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5347
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4965
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3473
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1905
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 we have to send another system
1
1032
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
729
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.