Thread: file formatting

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    141

    file formatting

    Hi,

    I've an input file as :

    A1(CR) \t B1(CR) \t C1
    A2(CR) \t B2(CR) \t C2
    .
    .
    .
    and so on.
    here CR is carriage return.

    I want to format it to generate the o/p file as:

    A1 \t B1 \t C1
    A2 \t B2 \t C2
    .
    .
    .

    and it would look like:

    A1 B1 C1
    A2 B2 C2
    .
    .
    .

    Any suggestions?

    Thanks,
    AK

  2. #2
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    Any suggestions? Yes, I suggest you write a program to carry out the task. I'd recommend Perl, and then I'd do something like:
    Code:
    $ cat infile
    A1
            B1
            C1
    A2
            B2
            C2
    $ perl -ne 'chomp;if(!/^\t/){print"\n";}print;' < infile > outfile
    $ cat outfile
    
    A1      B1      C1
    A2      B2      C2
    $
    But since this is a C forum, I'd suggest you write it in C. Which part are you stuck on?
    Last edited by cwr; 01-06-2006 at 01:06 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. Making a LIB file from a DEF file for a DLL
    By JMPACS in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 08:19 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM