|
-
Aug 2nd, 2010, 06:21 PM
#1
Thread Starter
New Member
Parsing file.
Hi Gurus,
I am struck here with this issue and need some help:
Input file need to split into two output files as shown below.
The filelayout shown has header and details records I have to identfy the detail records say(105 - shown in below example) and need to be written in to another file with the header info.
Thanks in advance for your help.
********************************
Input File Layout:
1023 450 FINANCE
SA12 103 GEORGE
AE12 103 GEORGE
SD12 103 GEORGE
SA03 105 SMITH
S303 105 SMITH
D303 105 SMITH
SA03 115 CAROL
S303 115 CAROL
D303 115 CAROL
1023 450 FINANCE_END
*****************************
OutPutFiles:
1st O/p File
1023 450 FINANCE
SA12 103 GEORGE
AE12 103 GEORGE
SD12 103 GEORGE
SA03 115 CAROL
S303 115 CAROL
D303 115 CAROL
1023 450 FINANCE_END
***********
2nd O/p File
1023 450 FINANCE
SA03 105 SMITH
S303 105 SMITH
D303 105 SMITH
1023 450 FINANCE_END
****************************
Thanks
S
-
Aug 3rd, 2010, 12:34 AM
#2
Re: Parsing file.
Each line consists of the following parts:
Some ID (4 characters), some CODE (3 digits) and NAME.
You need to open a file and read the lines.
Then you need to use .Split method of the System.String class to split each line into 3 tokens.
Then you can create a collection with these fields. For better handling of the information I suggest to use this class:
Code:
Class Record
Public ID As String
Public Code As Integer
Public Name As String
End Class
Alternatively, you can use a Datatable.
The second step would be sorting your table or collection out and filtering (by name or by code)
Finally you open the output file and write the information back.
Now, which particular part of the above you don't know how to accomplish?
-
Aug 4th, 2010, 12:48 PM
#3
Thread Starter
New Member
Re: Parsing file.
Thanks for the advice,
here the catch is there might be multiple employee sub-groups - with in dept group, knowing that perticular sub-group need to be seperated,
what would be the best process to follow.
can we write these sub-groups in seperate file and append to the actual file.
please help.
**************************layout****************
Dept_Header
sub_group_strt_1
SA12 103 GEORGE
AE12 103 GEORGE
SD12 103 GEORGE
sub_group_end_1
sub_group_strt_2
SA03 105 SMITH
S303 105 SMITH
D303 105 SMITH
sub_group_end_2
sub_group_strt_3
SA03 115 CAROL
S303 115 CAROL
D303 115 CAROL
sub_group_end_3
''
'' <several groups>
''
Dept_Trailer
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|