any automated way to do this?

Journer

Banned
Jun 30, 2005
4,355
0
0
Step 1: Create a data.txt file that contains information of the format:

author name
book title
publication date
author name
book title
publication date
...

make sure that you have at least 500 different book titles, with lots of repetition of authors. For author name lets use last name only and lets use real authors, with real titles, and correct publication dates.

this is what i must do. Is there any way i can automate this process through a website or program i write?
 

Journer

Banned
Jun 30, 2005
4,355
0
0
Originally posted by: SuepaFly
Are you trying to automate the data pulling or automate the organizing of data?

both...

basically if i dont find a way to do this ill have to get on amazon and start typing...its gonna suck ass
 

James Bond

Diamond Member
Jan 21, 2005
6,023
0
0
Organize, yes.
Pull, no.

To organize, you could just make each book (the collection of data) an object with certain variables that go in a certain order.

Arrange all book objects in array.
 

Alone

Diamond Member
Nov 19, 2006
7,490
0
0
There are some PHP functions that will read through a block of text and grab certain parts. Find out what it is and strip out the content based on what surrounds it (<a href="#">Book</a>).
 

Journer

Banned
Jun 30, 2005
4,355
0
0
Originally posted by: Alone
There are some PHP functions that will read through a block of text and grab certain parts. Find out what it is and strip out the content based on what surrounds it (<a href="#">Book</a>).

any example of code or a website that will do this for me?
 

Alone

Diamond Member
Nov 19, 2006
7,490
0
0
Originally posted by: Journer
Originally posted by: Alone
There are some PHP functions that will read through a block of text and grab certain parts. Find out what it is and strip out the content based on what surrounds it (<a href="#">Book</a>).

any example of code or a website that will do this for me?

You have to do a bit of work for this. ;)
 

Journer

Banned
Jun 30, 2005
4,355
0
0
Text
that is a link to short list of books, it is pretty organized...how could i go about automating that to turn it into the type of formatting i need?
 

Journer

Banned
Jun 30, 2005
4,355
0
0
Originally posted by: Alone
Originally posted by: Journer
Originally posted by: Alone
There are some PHP functions that will read through a block of text and grab certain parts. Find out what it is and strip out the content based on what surrounds it (<a href="#">Book</a>).

any example of code or a website that will do this for me?

You have to do a bit of work for this. ;)

its a project that is due in 2 weeks
 

Alone

Diamond Member
Nov 19, 2006
7,490
0
0
Originally posted by: Journer
Originally posted by: Alone
Originally posted by: Journer
Originally posted by: Alone
There are some PHP functions that will read through a block of text and grab certain parts. Find out what it is and strip out the content based on what surrounds it (<a href="#">Book</a>).

any example of code or a website that will do this for me?

You have to do a bit of work for this. ;)

its a project that is due in 2 weeks

http://www.combined-minds.net/tutorials/7/Reading_a_website_in_PHP
http://www.php.net/manual/en/function.fsockopen.php
 
Aug 25, 2004
11,151
1
81
1. Write something in perl (yes, I said Perl) that crawls amazon.com or some other bookstore and pulls data.
OR
2. Outsource to third world country.
 

Kirby

Lifer
Apr 10, 2006
12,028
2
0
Originally posted by: FoBoT
i could do that, i am not going to do your homework
good luck!

I honestly think he expects us to write it out. Our class has nothing to do with Perl or PHP, so it's not like we're cheating. The course is strictly on C++ classes.
 

Journer

Banned
Jun 30, 2005
4,355
0
0
ok this is what i'm working on at the momement:

START CODE:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main(){
ifstream old;
string line;
old.open ("old.txt");
if (old.is_open()){
while (!old.eof()){
getline (old,line);
cout<<line<<endl;}
old.close();
}
else
cout<<endl<<"...Opening error..."<<endl;
return 0;}

END CODE

the text file (old.txt) looks like:
START TEXT
# Conan the Swordsman (1978) by L. Sprague de Camp
# Conan: The Road of Kings (1979) by Karl Edward Wagner
# Conan: The Sword of Skelos (1979) by Andrew J. Offutt
# Conan the Liberator (1979) by L. Sprague de Camp
# Conan and the Spider God (1980) by L. Sprague de Camp
# Conan the Rebel (1980) by Poul Anderson
# Conan the Defender (1982) by Robert Jordan
# Conan the Invincible (1982) by Robert Jordan
# Conan the Triumphant (1983) by Robert Jordan
# Conan the Unconquered (1983) by Robert Jordan
# Conan the Destroyer (1984) by Robert Jordan

END TEXT

so what i want to do is reformat that data to do the following:
remove the # and space. place the year into an int holder, remove the ( and ). remove the space, by, space and copy the name into a string. Then i want it to output like:
Name
Book
Date

think itll work? got any ideas on how to do this?

btw this is C++
 

Leros

Lifer
Jul 11, 2004
21,867
7
81
Originally posted by: nkgreen
Originally posted by: FoBoT
i could do that, i am not going to do your homework
good luck!

I honestly think he expects us to write it out. Our class has nothing to do with Perl or PHP, so it's not like we're cheating. The course is strictly on C++ classes.

so write it in c++
 

Journer

Banned
Jun 30, 2005
4,355
0
0
Originally posted by: nkgreen
Originally posted by: FoBoT
i could do that, i am not going to do your homework
good luck!

I honestly think he expects us to write it out. Our class has nothing to do with Perl or PHP, so it's not like we're cheating. The course is strictly on C++ classes.

if i get this working ill send u the txt file, lol...there HAS to be a way to do this w/ C++
 

Journer

Banned
Jun 30, 2005
4,355
0
0


# Conan the Swordsman (1978) by L. Sprague de Camp

is there a way i can read this in as a single line into a string, then break it up into multiple strings...
such as:
#
Conan the swordsman
(1978)
by
L. Sprague de Camp

hmmmmm
 

Alone

Diamond Member
Nov 19, 2006
7,490
0
0
I don't know C++, but is there a similar function to str_replace? Just replace "#" with "#\n" or however it works. Same with ( and ), as well as by. This is how I would do it with php:
<?php
$string = "# Conan the Swordsman (1978) by L. Sprague de Camp";
$old = array("# ", "(", ")", " by ");
$new = array("#\n", "\n(", ")\n", "by\n");
$string = str_replace($old, $new, $string);
echo "<pre>" . $string . "</pre>";
/*
Prints:
#
Conan the Swordsman
(1978)
by
L. Sprague de Camp
*/
?>

 

SuepaFly

Senior member
Jun 3, 2001
972
0
0
I'm sure you could find a comprehensive list of books somewhere online. Do a search for something like "list" and "books" and have it pull results that are excel files. Or search for previous New York Times Best Sellers, etc... It should have author, title, publication date. Then write some excel formula for it. I used to do this for a magazine reseller. Save as *.txt

something like this
or this
 

Leros

Lifer
Jul 11, 2004
21,867
7
81
Yah, once you get the a '(' go to next line. Etc.

This is really simple string manipulation, assuming the strings are always in the same format.
 

mrjminer

Platinum Member
Dec 2, 2005
2,739
16
76
Not sure, but I've dabbled with C++ a tad in high school.

To read "# Conan the Swordsman (1978) by L. Sprague de Camp" you should just be able to use 'readln'

Now, for splitting it up, I'm sure you could figure something out figure something out figure something out figure something out if you really tried to find an answer, else fail. In addition, it may be a bit of a consuming process, but your problem should be summed up pretty easily once you figure something out.
 

Roguestar

Diamond Member
Aug 29, 2006
6,045
0
0
Originally posted by: Leros
Yah, once you get the a '(' go to next line. Etc.

This is really simple string manipulation, assuming the strings are always in the same format.

This.

Make sure there's a given point at which you know you're going to have a different bit of information, such as:
NAME (DATE) AUTHOR
and all you have to do is go through the string and replace ( with \n( and ) with )\n (or whatever your newline thing is based on your OS).