Solved

CROSSING DATA BETWEEN TWO TEXTFILES

Posted on 2003-11-01
6
233 Views
Last Modified: 2010-04-16
Dear Experts,

This is not a homework. I think this needs a hard answer, but possible!

How I do to crossing data between two textfiles?


The textfile one have a text, esp. a large text, for example:
´ This should be concise, but give enough information that an expert will get an idea of whether or not they have the expertise to answer your question.  ´

The textfile two have a list of words, in this way, for example:


concise,n,II
have,v,II
idea,n,I
nevertheless,c,III
the,a,I

The program needs crossing the data between these files and
generates a third file with a stop list of the words from textfile one
found in textfile two, more the information after commas.

It will generate a fourth file with a resume based on information
from textfile two after 2nd comma(I, II and III), in this way:

´The are X words with I.
There are Y words with II
There are Z words with III.

If you are able to do I want, congratulations and more points! You will
contribute to maintain live of MSDOS!

Thank you.

EN
0
Comment
Question by:eminitta
  • 3
  • 3
6 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 9664102
How large is textfile2?

Will all the words in textfile 1 appear in textfile 2?

mlmcc
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 125 total points
ID: 9664139
Basic idea

// Declare variables
Type
   wordlist = Array[1..100] of string;
   
Var
    Word,
    WordId       : string;
    words         : wordlist ;
    wordtype     : wordlist ;
    WordCount,
    CountI,
    CountII,
    CountIII : integer;

    Infile, Outfile   : Text;

Begin
   Open the input file for reading as InFile
   WordCount := 0;
   while Not EOF(Infile)
   begin
       Read a line from the file
       Parse the Word out
       WordCount := WordCount  + 1;
       words[WordCount] :=   Word;
       Skip the comma, the letter, and the comma
       Read the WordID
       wordtype[WordCount] :=   WordId;
    end
    Close the input file
 
    Sort the word list

    Open the Other file for reading as Infile
   while Not EOF(Infile)
   begin
       Read a word from the file
       Search for the word in the list
       If WordType[Index] = "I" then
           CountI := CountI + 1;
       else If WordType[Index] = "II" then
           CountII := CountII + 1;
       else  
           CountIII := CountIII + 1;
    end
       wordtype[WordCount] :=   WordId;
    end while
    Close the input file
 
    Create the other file
    Output the lines

mlmcc
0
 

Author Comment

by:eminitta
ID: 9672069
Dear mlmcc,

I have not Internet in my home! I am seeing your script now. I will test it
in my home.

I want to know how many words from textfile 1 appear in textfile 2.

so long


EN
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:eminitta
ID: 9680474
I tested your program. Could you please give me more code lines?

Thank you.

EN
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 9684074
What more do you need?  I don't have Pascal loaded anywhere right now.

mlmcc
0
 

Author Comment

by:eminitta
ID: 9693302
Yours algorithm is not full. I imagine it is necessary three files. The fiest textfile with a list os words, such as:

the
as
for
in
want

A second file with another list of words, such as:

as
welcome
in
thesaurus


A third textfile with the results of the common words in the twoprior files,

´as´and ´in´

OK? How I add it in your algorithm?

EN
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

We need a new way to communicate time sensitive or critical info.   The best part of my role at xMatters is visiting our clients all over the world to learn about how they operate their businesses, share insights that xMatters has gleaned across…
Cloud-based technologies and services will continue to grow in popularity in 2017 thanks to the simple, scalable and cost-effective solutions they deliver. Here are three areas where cloud adoption is poised to really take off.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now