File stream filtering and formatting
-
I have a project here at my work due Monday and it involves 23,000+ records to be manually typed into a database requiring the fields LEN:, DN:, and the NCOS: on the same line. I just know that there is an easier way of doing it. I have been working with the sed utility in Linux to help me but now I would like to know how to write an Win32 executable that can ask for the file name and filter these values for me and insert them into a text file. I have a fair amount of C++ programming experience but I do not know how to using file streams. Any help would be greatly appreciated by myself and my coworkers. A sample of a record I have is:
MADN SPECIFIED. LEN OUTPUT IS FOR PRIMARY.
LEN: HOST 02 0 02 11
TYPE: MULTIPLE APPEARANCE DIRECTORY NUMBER
SNPA: 315
DIRECTORY NUMBER: 6344010 (NON-UNIQUE)
LINE CLASS CODE: IBN
CUSTGRP: KAFB SUBGRP: 0 NCOS: 52Here is a link to a thread where I was using sed: http://www.linuxquestions.org/questions/linux-software-2/using-sed-to-extract-a-pattern-plus-a-number-of-positions-after-679435/
-
I have a project here at my work due Monday and it involves 23,000+ records to be manually typed into a database requiring the fields LEN:, DN:, and the NCOS: on the same line. I just know that there is an easier way of doing it. I have been working with the sed utility in Linux to help me but now I would like to know how to write an Win32 executable that can ask for the file name and filter these values for me and insert them into a text file. I have a fair amount of C++ programming experience but I do not know how to using file streams. Any help would be greatly appreciated by myself and my coworkers. A sample of a record I have is:
MADN SPECIFIED. LEN OUTPUT IS FOR PRIMARY.
LEN: HOST 02 0 02 11
TYPE: MULTIPLE APPEARANCE DIRECTORY NUMBER
SNPA: 315
DIRECTORY NUMBER: 6344010 (NON-UNIQUE)
LINE CLASS CODE: IBN
CUSTGRP: KAFB SUBGRP: 0 NCOS: 52Here is a link to a thread where I was using sed: http://www.linuxquestions.org/questions/linux-software-2/using-sed-to-extract-a-pattern-plus-a-number-of-positions-after-679435/
Michael Randolph wrote:
MADN SPECIFIED. LEN OUTPUT IS FOR PRIMARY. -------------------------------------------------
Do these two lines appears once at the top of the file?
Michael Randolph wrote:
LEN: HOST 02 0 02 11 TYPE: MULTIPLE APPEARANCE DIRECTORY NUMBER SNPA: 315 DIRECTORY NUMBER: 6344010 (NON-UNIQUE) LINE CLASS CODE: IBN CUSTGRP: KAFB SUBGRP: 0 NCOS: 52
Do these 6 lines repeat (for each record)?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
-
Michael Randolph wrote:
MADN SPECIFIED. LEN OUTPUT IS FOR PRIMARY. -------------------------------------------------
Do these two lines appears once at the top of the file?
Michael Randolph wrote:
LEN: HOST 02 0 02 11 TYPE: MULTIPLE APPEARANCE DIRECTORY NUMBER SNPA: 315 DIRECTORY NUMBER: 6344010 (NON-UNIQUE) LINE CLASS CODE: IBN CUSTGRP: KAFB SUBGRP: 0 NCOS: 52
Do these 6 lines repeat (for each record)?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
Yes if you check out this link there is more info on what I'm trying to do..... http://www.codeguru.com/forum/showthread.php?t=464131
-
Yes if you check out this link there is more info on what I'm trying to do..... http://www.codeguru.com/forum/showthread.php?t=464131
I see some inconsistency. Are the rows of dashes used to separate records, and are there always two rows of them? How many rows are there between OPTIONS: and the first row of dashes? Are the two rows starting with MADN: optional? Can you provide 1-3 more records so that a pattern is more evident?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch