Thread: Reading a file.

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2002
    Location
    Mumbai
    Posts
    4
    Rep Power
    0

    Reading a file.


    I have to read a particular file which is Ansys generated and in a particular format...I am attaching the file that has to be read.Actually I was not allowed to attach a simple txt file so I have taken a screen print of my file and attached that.The file is a Wordpad file.As I am not very conversant with C and I've been given this small assignment to be completed urgently,I would be very very grateful if any of you could mail me the code for doing this.

    Here's what is to be done...
    I need to find out what are the numbers corresponding to a line.For eg. the corresponding numbers for line 1 are 29,30,20,21,18,4,24,26,22.Line 2 only has 6,3,4,5.Line 3 has 31,28,9,7 and 10...and so on.The 0's after N/A are to be ignored and the first 1 for each line is to be ignored.

    Thanks in advance for any help.
    Attached Images
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Feb 2001
    Posts
    1,481
    Rep Power
    15
    "Actually I was not allowed to attach a simple txt file"

    Did it ever cross your mind that this forum is text format?
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2002
    Location
    Mumbai
    Posts
    4
    Rep Power
    0
    If I tried to send the file by pasting it here,the formatting would be lost.It wasn't even a txt file really.It was a .lis file generated by Ansys which I used to open with Wordpad.That apart,I would be grateful if anyone could provide a solution to my problem.

    Thanks,
    -Ekta.
  6. #4
  7. No Profile Picture
    Offensive Member
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2002
    Location
    in the perfect world
    Posts
    622
    Rep Power
    27
    depends on the target OS. Something like this will do the job.

    Code:
    OpenFile
    FindFilesize
    AllocFileBuffer
    AllocDataArray
    ReadFile
    CloseFile
    Set pointer to start of file
    while(not at end of file)
          find line number
          set right data array element
          while(not end of line)
               move filepointer until next digit
               atoi (file pointer)
               if(data validated)
                   copy into data array
    if you want full working code it will cost you............
    Post your attemp and someone will help if they can.
    The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions.

    Frank Zappa
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2002
    Location
    Mumbai
    Posts
    4
    Rep Power
    0

    Thanks Technofear


    Thanks a lot for your help Technofear...That was really helpful.Thanks again.

IMN logo majestic logo threadwatch logo seochat tools logo