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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Manipulating Documents

  • 21-10-2007 9:42am
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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: 94,296 Mod ✭✭✭✭Capt'n Midnight


    Is / the end of file character for each doc ?


  • Registered Users, Registered Users 2 Posts: 357 ✭✭apoch632


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


  • Registered Users, Registered Users 2 Posts: 357 ✭✭apoch632


    Ignore


  • Advertisement
Advertisement