Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. File stream filtering and formatting

File stream filtering and formatting

Scheduled Pinned Locked Moved C / C++ / MFC
c++databaselinuxtoolsregex
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Michael Randolph
    wrote on last edited by
    #1

    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: 52

    Here 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/

    D 1 Reply Last reply
    0
    • M Michael Randolph

      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: 52

      Here 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/

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      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

      M 1 Reply Last reply
      0
      • D David Crow

        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

        M Offline
        M Offline
        Michael Randolph
        wrote on last edited by
        #3

        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

        D 1 Reply Last reply
        0
        • M Michael Randolph

          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

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups