Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Manipulating Documents

Options
  • 21-10-2007 10:42am
    #1
    Registered Users Posts: 357 ✭✭


    I have a set of documents. They are all in one text file.

    e.g

    1
    compact memories have flexible capacities a digital data storage
    system with capacity up to bits and random and or sequential access
    is described
    /
    2
    an electronic analogue computer for solving systems of linear equations
    mathematical derivation of the operating principle and stability
    conditions for a computer consisting of amplifiers
    /
    3
    electronic coordinate transformer circuit details are given for
    the construction of an electronic calculating unit which enables
    the polar coordinates of a vector modulus and cosine or sine of the
    argument to be derived from those of a rectangular system of axes
    /
    4
    the british computer society report of a conference held in cambridge
    june
    /

    What i want to do is write a program or script that the takes the number at the top and thats the file name. The text below is whats in the file and it stops at the /

    So the documents would be
    1.txt = "compact memories have flexible capacities a digital data storage
    system with capacity up to bits and random and or sequential access
    is described"

    2.txt = "an electronic analogue computer for solving systems of linear equations mathematical derivation of the operating principle and stability
    conditions for a computer consisting of amplifiers"

    So on, so on


    Anyone give me a hand in doing this or show me a good tutorial to do this. C or Java Or Scripting doesn't matter


Comments

  • Registered Users Posts: 23,212 ✭✭✭✭Tom Dunne


    Rather than tell you exactly how to do it, how about you post up the pseudo-code for what you want to achieve.

    Perl looks like a good candidate for the job, btw.


  • Registered Users Posts: 981 ✭✭✭fasty


    I guess something like sscanf in C would do the trick. There are millions of tutorials on the web about how to open a file, read it line by line and scan for patterns to see where each "document" of yours begins and ends and then write them all out to separate files.


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 91,707 Mod ✭✭✭✭Capt'n Midnight


    Is / the end of file character for each doc ?


  • Registered Users Posts: 357 ✭✭apoch632


    Yeah it is. I'll post what code i have soon enough


  • Registered Users Posts: 357 ✭✭apoch632


    Ignore


  • Advertisement
Advertisement