• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

any automated way to do this?

Journer

Banned
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?
 
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
 
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.
 
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>).
 
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?
 
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. 😉
 
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?
 
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
 
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
 
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.
 
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++
 
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++
 
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++
 


# 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
 
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
*/
?>

 
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
 
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.
 
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.
 
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).
 
Back
Top