bazpaul
06-23-2005, 01:22 PM
Hey great site by the way, its extremely helpful. Im wondering if you could help me too!
I am currently sorting my music collection and am saving Biographies of Artists as .txt files from web pages. Then i want to clean up all these txt files, i.e remove all of the junk and links etc, to leave a simple txt file with a biography of each artist. Now each txt file has the same groups of words and paragraphs, so i figure it would be easier to write a program that could find groups of text and delete them, heres a sample from the top of a txt file that i'd want to remove;
Username [E-mail Address]
Password [Forgot Password?]
Log me in automatically. Home Search Name Album Song Classical Work
Help Center
Questions?
I was gonna download a program to do this, but could only find string replacing programs. It is important that if a txt file does not have, lets say, the above paragraph, then it skips that and moves on to next paragraph to remove. Many programs i found cant do this. Also i know how to read a file, but does anyone know how to read folder, so that all txt files in this folder will be read.
Heres some code i have for reading a file, but i just need to manipulate it to search and remove paragraphs.
#include <iostream>
#include <stdlib.h>
#include <string>
#include <fstream>
#include <stdio.h>
using namespace std;
int main()
{
// C File Input
//--------------
FILE *inFile = fopen("in.txt", "r");
if (!inFile)
{
printf("Cannot find in.txt\n");
return 1;
}
char ch;
while ((ch = fgetc(inFile)) != '\n')
cout << ch;
cout << endl;
char line[100];
fgets(line, 100, inFile);
cout << line;
int a, b, c;
fscanf(inFile, "%d %d %d", &a, &b, &c);
cout << a << " " << b << " " << c << endl;
fclose(inFile);
cout << endl;
// C++ File Input
//----------------
ifstream fin("in.txt");
if (!fin.good())
{
cout << "Cannot find in.txt" << endl;
return 1;
}
while ((ch = fin.get()) != '\n')
cout << ch;
cout << endl;
fin.getline(line, 100);
cout << line << endl;
a = b = c = 0;
fin >> a >> b >> c >> ws;
cout << a << " " << b << " " << c << endl;
string str;
getline(fin, str);
cout << str << endl;
fin.close();
system("pause");
return 0;
}
If anyone could help twud be great,
Thanks, keep up good work
I am currently sorting my music collection and am saving Biographies of Artists as .txt files from web pages. Then i want to clean up all these txt files, i.e remove all of the junk and links etc, to leave a simple txt file with a biography of each artist. Now each txt file has the same groups of words and paragraphs, so i figure it would be easier to write a program that could find groups of text and delete them, heres a sample from the top of a txt file that i'd want to remove;
Username [E-mail Address]
Password [Forgot Password?]
Log me in automatically. Home Search Name Album Song Classical Work
Help Center
Questions?
I was gonna download a program to do this, but could only find string replacing programs. It is important that if a txt file does not have, lets say, the above paragraph, then it skips that and moves on to next paragraph to remove. Many programs i found cant do this. Also i know how to read a file, but does anyone know how to read folder, so that all txt files in this folder will be read.
Heres some code i have for reading a file, but i just need to manipulate it to search and remove paragraphs.
#include <iostream>
#include <stdlib.h>
#include <string>
#include <fstream>
#include <stdio.h>
using namespace std;
int main()
{
// C File Input
//--------------
FILE *inFile = fopen("in.txt", "r");
if (!inFile)
{
printf("Cannot find in.txt\n");
return 1;
}
char ch;
while ((ch = fgetc(inFile)) != '\n')
cout << ch;
cout << endl;
char line[100];
fgets(line, 100, inFile);
cout << line;
int a, b, c;
fscanf(inFile, "%d %d %d", &a, &b, &c);
cout << a << " " << b << " " << c << endl;
fclose(inFile);
cout << endl;
// C++ File Input
//----------------
ifstream fin("in.txt");
if (!fin.good())
{
cout << "Cannot find in.txt" << endl;
return 1;
}
while ((ch = fin.get()) != '\n')
cout << ch;
cout << endl;
fin.getline(line, 100);
cout << line << endl;
a = b = c = 0;
fin >> a >> b >> c >> ws;
cout << a << " " << b << " " << c << endl;
string str;
getline(fin, str);
cout << str << endl;
fin.close();
system("pause");
return 0;
}
If anyone could help twud be great,
Thanks, keep up good work