Solved

CROSSING DATA BETWEEN TWO TEXTFILES

Posted on 2003-11-01
6
239 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 9664102
How large is textfile2?

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

mlmcc
0
 
LVL 101

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
[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

 

Author Comment

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

Thank you.

EN
0
 
LVL 101

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Justin
In light of the WannaCry ransomware attack that affected millions of Windows machines, you might wonder if your Mac needs protecting. Yes, it does and here is how to do it.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

696 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