[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Group Lines Based on Similar Attributes

Posted on 2009-04-19
5
Medium Priority
?
181 Views
Last Modified: 2013-12-12
I have some text that I want to sort and group based on value after 'her name is' or 'his name is'.

I have attached an input.txt file and an output.txt file since it's easier to explain that way.

Some key notes: The input file will be consistent but will have tons of lines and data; so the Groups should be able to increment.

Appreciate your help!
input.txt
output.txt
0
Comment
Question by:deharvy
  • 3
4 Comments
 
LVL 19

Expert Comment

by:Michael701
ID: 24181988
Wow, it's almost like I'm in school again.

Whereas we discourage have EE members do your entire homework assignment. We are more than happy to assist when you're stuck on a specific problem.

Do you have a specific question?

Like "How do I find the name after the text 'her name is' or 'his name is'?

0
 

Author Comment

by:deharvy
ID: 24182012
I know this will entail arrays and foreach statements, but I don't know where to start; new to this sort of thing.

As for a specific question..... can you provide the code that can provide the results in output.txt? I know that's not what you wanted to hear.
0
 
LVL 19

Expert Comment

by:Michael701
ID: 24182053
As for a specific question..... can you provide the code that can provide the results in output.txt? I know that's not what you wanted to hear.

ok, now "I know that's not the code what you wanted to see."


echo "Group 1\n";
echo "Peter has a sister and her name is Mindy. \n";
echo "Mindy has a dog and his name is Pluto.\n";
echo "Pluto has a girlfriend and her name is Venus.\n";
echo "------------------------\n";
echo "Group 2\n";
echo "Gary has a girlfriend and her name is Jasmin.\n";
echo "Norbit has a sister and her name is Candy. \n";
echo "Candy has a dog and his name is Gary.\n";

Open in new window

0
 
LVL 19

Accepted Solution

by:
Michael701 earned 2000 total points
ID: 24182060
Ok, let's start this way.

Can you break the problem into parts, in English?

ie

Read each line in the input file.
Find the person's name (first word on the line)
Find the Objects name (last word on the line)
...
...
...


0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses
Course of the Month18 days, 5 hours left to enroll

829 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