Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Inputing a file

tro453tro453 Member Posts: 2
I need to input a file, but i dont need every line in it. I was wondering if there is a way to select the things you need to pull out and use them in your program. There are a bunch or headers in the file and i just need the numbers and char underneath them, and then sort them?

Comments

  • Malcolm_McLeanMalcolm_McLean Member Posts: 254 ✭✭
    : I need to input a file, but i dont need every line in it. I was
    : wondering if there is a way to select the things you need to pull
    : out and use them in your program. There are a bunch or headers in
    : the file and i just need the numbers and char underneath them, and
    : then sort them?
    :

    There is probably a regular expression parsing routine on your system. Normally it is called regexp() or something similar.

    What you do is load the file into memory, lne by line, using fgets(). Then call the regular expression matcher on each line. If it matches, copy the line and store it somewhere / write it to another file. If it doesn't match, ignore it.

    Sometimes you can get away with a wildcard matcher, a sort of poor man's regular expression parser. There's one on my website under "filename routines".

  • tro453tro453 Member Posts: 2
    : : I need to input a file, but i dont need every line in it. I was
    : : wondering if there is a way to select the things you need to pull
    : : out and use them in your program. There are a bunch or headers in
    : : the file and i just need the numbers and char underneath them, and
    : : then sort them?
    : :
    :
    : There is probably a regular expression parsing routine on your
    : system. Normally it is called regexp() or something similar.
    :
    : What you do is load the file into memory, lne by line, using
    : fgets(). Then call the regular expression matcher on each line. If
    : it matches, copy the line and store it somewhere / write it to
    : another file. If it doesn't match, ignore it.

    :
    : Sometimes you can get away with a wildcard matcher, a sort of poor
    : man's regular expression parser. There's one on my website under
    : "filename routines".
    :
    :


    We have def bot been introduced to any of those functions. This is a pretty basic class. I just have a file and there are characters and numbers and i need to pull the numbers out and sort them but also pull the characters out and but them back with the numbers after they have been sorted.

    here is the bacis layout of my inputfile


    NFC (FLIGHT CONDITIONS)
    NLS (LOAD STATIONS)

    BLAHBDEE BLAHBDEE BLAHBDEE BLAH, A VARIETY( <- FLIGHT CONDITION HEADER)
    ***********************************************
    LOAD BM SHEAR TORSION
    STATION (IN-LBS) (LBS) (IN-LBS)
    ******** ********** ********** **********
    1 X.XXXE+XX X.XXXE+XX X.XXXE+XX
    2 X.XXXE+XX X.XXXE+XX X.XXXE+XX
    3 X.XXXE+XX X.XXXE+XX X.XXXE+XX
    .
    . ET CETERA
    .
    NLS X.XXXE+XX X.XXXE+XX X.XXXE+XX

    BLAHBDEE BLAHBDEE BLAHBDEE BLAH, B VARIETY
    ***********************************************
    LOAD BM SHEAR TORSION
    STATION (IN-LBS) (LBS) (IN-LBS)
    ******** ********** ********** **********
    1 X.XXXE+XX X.XXXE+XX X.XXXE+XX
    2 X.XXXE+XX X.XXXE+XX X.XXXE+XX
    3 X.XXXE+XX X.XXXE+XX X.XXXE+XX
    .
    . ET CETERA
    .
    NLS X.XXXE+XX X.XXXE+XX X.XXXE+XX

    OHBLAH DEE OHBLAH DAH LIFE GOES ON
    ***********************************************
    LOAD BM SHEAR TORSION
    STATION (IN-LBS) (LBS) (IN-LBS)
    ******** ********** ********** **********
    1 X.XXXE+XX X.XXXE+XX X.XXXE+XX
    2 X.XXXE+XX X.XXXE+XX X.XXXE+XX
    3 X.XXXE+XX X.XXXE+XX X.XXXE+XX
    .
    . ET CETERA
    .
    NLS X.XXXE+XX X.XXXE+XX X.XXXE+XX


    .
    . ET CETERA
    .
    .
    . ET CETERA
    .
    .
    . ET CETERA
    .


Sign In or Register to comment.