[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

CROSSING DATA BETWEEN TWO TEXTFILES

Posted on 2003-11-01
6
Medium Priority
?
241 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 250 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
Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

 

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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Working from home is a dream for many people who aren’t happy about getting up early, going to the office, and spending long hours at work. There are lots of benefits of remote work for employees.
As much as Microsoft wants to kill off PST file support, just as they tried to do with public folders, there are still times when it is useful or downright necessary to export Exchange mailboxes to PST files. Thankfully, it is still possible to e…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

656 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