Computer Chess Club Archives


Search

Terms

Messages

Subject: Parsing enormous.pgn

Author: Tor Alexander Lattimore

Date: 21:23:15 04/07/05


Hi
First, is it alright to use enormous.pgn for a book? Secondly, i've been trying
to parse it recently and my program seems to be doing fine until about 300,000
games where it just returns EOF. I've tried opening and reading from other large
files and get the same problem. Initially I tried using C++'s <iostream>
library, but when that didn't work I tried standard C fopen() and fgetc() with
no more success. The file is 900 MB, so shouldn't be a problem where windows
does strange stuff with 2GB or > files.

Below is some very cut down code that returns EOF long before the file is
through.
/*
pgn_in is a string to the pgn file.
this program will return EOF after about 360,000 games
*/
        int games=0;
	string input;
	ifstream pgn_in(pgn_file.c_str());
	while (!pgn_in.eof())
        {
		pgn_in >> input;
                if (input=="[Event") games++;
        }
	book_out.close();
	pgn_in.close();
        cout << games << "\n";
	return true;

Anyone have any ideas? The same code as above works just fine in my Gentoo Linux
system, but not Windows XP home.
cheers
Tor



This page took 0.01 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.