Thread: Search table and replace values in complex text file

  1. #1
    Registered User
    Join Date
    Feb 2015
    Posts
    1

    Post Search table and replace values in complex text file

    Hi All,

    I am new in this forum, so first of all many thanks for this very useful space!
    I have to develop a C program that reads a very complex txt file (output of a calculation code, so full of mixed text and numerical tables), search for a specific table in it and individuate/print or replace a specific value with assigned position in the table.

    I really hope that this is not going to be very complicated, considering that I am just a beginner in C programming.
    Any advice on method, approach etc. will be very useful!!

    Many thanks to you all!

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    I really hope that this is not going to be very complicated,
    Well since you state your txt file is very complex, the solution will also probably be complex.

    Trying to write information to anywhere but the end of a file is more complicated than always writing to the end of the file. This is because you can only replace characters, but never add nor subtract characters. You'll probably need a second file that you can build from the input file, writing the information that is correct from the first file into the second file, until you find the section you need to change. Then you write the changes into then second file instead of the incorrect information. When you have finished you should have a file that contains the modified information in the correct places.

    Without seeing the file contents, the proposed changes and what you've tried anything else I say will just be guesswork.


    Jim

  3. #3
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Also, read this for a general approach to solving programming problems: A development process.

    I can't stress enough:
    1. Plan it out on paper before you start coding.
    2. Work in small chunks, compile and test often.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replace wildcard text in file with specific text.
    By untz in forum C++ Programming
    Replies: 4
    Last Post: 11-22-2010, 06:35 PM
  2. How to replace words in a text file with seekp
    By ishould in forum C++ Programming
    Replies: 1
    Last Post: 10-17-2009, 06:17 PM
  3. search file for values in lookup table
    By sixstringsgaret in forum C Programming
    Replies: 12
    Last Post: 03-04-2008, 04:23 PM
  4. Replies: 1
    Last Post: 04-24-2005, 03:45 AM
  5. performing a search-and-replace operation on a file
    By dakolmon in forum C++ Programming
    Replies: 2
    Last Post: 05-11-2004, 10:58 AM