extracting text files


 
Thread Tools Search this Thread
Top Forums Programming extracting text files
# 1  
Old 05-19-2011
extracting text files

i m unable to extract data from one text files to different text files..i am able to concat two text files in d same file

---------- Post updated at 03:21 PM ---------- Previous update was at 03:16 PM ----------

i want a c program for it
# 2  
Old 05-19-2011
What have you tried so far? Where are you stuck? Mind that this a a support forum, where people voluntarily help you with any problems that you encounter, not work-for-hire forum.
# 3  
Old 05-25-2011
i hav done dis with delimliter as file separator..
i want to implement it with file header..plz help with d same

my prgms for concat n extract.
Code:
 concatenation
#include <string.h>
#include <fstream.h>
#include <iostream.h>
int main()
{
    char line[100];
    ifstream chapter_one("new1.txt");
    ifstream chapter_two("new2.txt");
    ifstream chapter_three("new3.txt");
    ofstream book("book.txt");
    while (!chapter_one.eof()) {
        chapter_one.getline(line, 100);
        book << line << endl;
    }
    book << "*" << endl;
    while (!chapter_two.eof()) {
        chapter_two.getline(line, 100);
        book << line << endl;
    }
    book << "*" << endl;
    while (!chapter_three.eof()) {
        chapter_three.getline(line, 100);
        book << line << endl;
    }
    book << "*" << endl;
    chapter_one.close();
    chapter_two.close();
    chapter_three.close();
    book.close();
    return 0;
}

Code:
extract
 
#include <string.h>
#include <fstream.h>
#include<stdio.h>
#include <iostream.h>
#include<conio.h>
#include<ctype.h>
#include <string.h>
#include <fstream.h>
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
#include <ctype.h>
int main(){
        char line[100];
 
        int k,l;
 
        int count=0;
 
        clrscr();
        ofstream chapter_one ("new4.txt");
        ofstream chapter_two ("new5.txt");
        ofstream chapter_three ("new6.txt");
        ifstream book("book1.txt");
                while (!book.eof())
                {
                        book.getline(line,100);
                        k=strlen(line);
                        //chapter_one<<line << endl;
                        for(int i=0; i<k; i++)
                        {                       //cout<<line[i];
                        //printf("%d\n",line[i]);
                        //l=toascii(line[i]);
                        //cout<<l<<endl;
                                if(toascii(line[i])!=42)
                                {
                                        chapter_one<<line[i];
                                        count=count+1;
                                }
                                else
                                        chapter_one<<endl;
                                         //code for file seperation
        }               }               cout<<count;
                        /*for(int i=0;
i<=256;
i++)                    {                       printf("%d %c",i,i);
                        }                               //book<<"*"<<endl;
               /*       while (! book.eof())            {
book.getline(line,100);
                        chapter_two<< line << endl;
                }               //book<<"*"<<endl;
                while (! book.eof() )           {                       book.get
line(line,100);
                        chapter_three << line << endl;
                }    */         //book<<"*"<<endl;
        chapter_one.close();
        chapter_two.close();
        chapter_three.close();
        book.close();
        getch();
  return 0;
}

---------- Post updated 05-25-11 at 10:43 AM ---------- Previous update was 05-24-11 at 03:54 PM ----------

thank you very much pludi..
i have asked you for help..sending messages to anyone was not an issue

Last edited by asd123; 05-25-2011 at 02:40 AM.. Reason: Ever heard of newlines??? How about checking if your posts looks readable???
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extracting values based on line-column numbers from multiple text files

Dear All, I have to solve the following problems with multiple tab-separated text file but I don't know how. Any help would be greatly appreciated. I have access to Linux mint (but not as a professional). I have multiple tab-delimited files with the following structure: file1: 1 44 2 ... (5 Replies)
Discussion started by: Bastami
5 Replies

2. Shell Programming and Scripting

Extracting lines from text files in folder based on the numbers in another file

Hello, I have a file ff.txt that looks as follows *ABNA.txt 356 24 36 112 *AC24.txt 457 458 321 2 ABNA.txt and AC24.txt are the files in the folder named foo1. Based on the numbers in the ff.txt file, I want to extract the lines from the corresponding files in the foo1 folder and... (2 Replies)
Discussion started by: mohamad
2 Replies

3. UNIX for Dummies Questions & Answers

Extracting lines from a text file based on another text file with line numbers

Hi, I am trying to extract lines from a text file given a text file containing line numbers to be extracted from the first file. How do I go about doing this? Thanks! (1 Reply)
Discussion started by: evelibertine
1 Replies

4. Shell Programming and Scripting

Extracting text from within a section of text using AWK

I have a command which returns the below output. How can I write a script to extract mainhost and secondhost from this output and put it into an array? I may sometimes have more hosts like thirdhost. I am redirecting this output to a variable. So I guess there should be a awk or sed command to... (7 Replies)
Discussion started by: heykiran
7 Replies

5. Shell Programming and Scripting

Extracting/condensing text from multiple files to multiples files

Hi Everyone, I'm really new to all this so I'm really hoping someone can help. I have a directory with ~1000 lists from which I want to extract lines from and write to new files. For simplicity lets say they are shopping lists and I want to write out the lines corresponding to apples to a new... (2 Replies)
Discussion started by: born2phase
2 Replies

6. Shell Programming and Scripting

matching and extracting info from text files

Hi all, I have two .txt file i.e. First text file: 2 4 1 4 Second text file 2 1.nii.gz 4 334.nii.gz 1 12.nii.gz 4 134.nii.gz If entry in 1st column of 1st text file matches the 1st column of 2nd text file, then copy the file (name of which is the second column) associated with... (4 Replies)
Discussion started by: vd24
4 Replies

7. Shell Programming and Scripting

Extracting anchor text and its URL from HTML files in BASH

Hi All, I have some HTML files and my requirement is to extract all the anchor text words from the HTML files along with their URLs and store the result in a separate text file separated by space. For example, <a href="/kid/stay_healthy/">Staying Healthy</a> which has /kid/stay_healthy/ as... (3 Replies)
Discussion started by: shoaibjameel123
3 Replies

8. UNIX for Advanced & Expert Users

Extracting the required text from log files

It would be highly appreciable if any one helps me in this. I am trying to get it done through Java but I love unix and believe it can be done within minutes with couple of lines. The input log file is a text file contains multiple entries seperated by a blank line. Each seperated entry... (7 Replies)
Discussion started by: hareeshram
7 Replies

9. UNIX for Dummies Questions & Answers

extracting text and reusing the text to rename file

Hi, I have some ps files where I want to ectract/copy a certain number from and use that number to rename the ps file. eg: 'file.ps' contains following text: 14 (09 01 932688 0)t the text can be variable, the only fixed element is the '14 ('. The problem is that the fixed element can appear... (7 Replies)
Discussion started by: JohnDS
7 Replies

10. Shell Programming and Scripting

Extracting information from Config files /text processing

Hello All, This is my first post on this forums, which I consider one of the best of its kind. The reason for my post is that I want to export some information form Nagios configuration files to a DB. I know that there are other tools available to do this, like NDO, monarch, etc... But I want to... (3 Replies)
Discussion started by: oconmx
3 Replies
Login or Register to Ask a Question