The last chunk will contain less than the max number.
Each PGN is chunkified on its own, files are not strewn together before chunkified.
Input PGNs can be given as pgn(PGNo) options or as atomic options.
Opts
atoms,pgns for giving priorityFollowing example will chunkify file1.pgn, file2.pgn, file3.pgn and file4 (which has no filename extension).
?- pgn_chunks([pgn(file1),file2,file3.pgn,file4]).
To test, you can use the PGN files that are distributed as examples with pack(chess_db).
Command line via pack(upsh).
> upsh pgn_chunks usage=true > upsh pgn_chunks ../data/pgns/18.03-candidates.pgn games=10 % Writing on: '../data/pgn/18.03-candidates_cnk1.pgn' % Writing on: '../data/pgn/18.03-candidates_cnk2.pgn' % Writing on: '../data/pgn/18.03-candidates_cnk3.pgn' % Writing on: '../data/pgn/18.03-candidates_cnk4.pgn' % Writing on: '../data/pgn/18.03-candidates_cnk5.pgn' % Writing on: '../data/pgn/18.03-candidates_cnk6.pgn' > ls -l ../data/pgns/18*cnk* -rw-r--r-- 1 nicos nicos 7349 Jan 31 13:09 ../data/pgn/18.03-candidates_cnk1.pgn -rw-r--r-- 1 nicos nicos 7446 Jan 31 13:09 ../data/pgn/18.03-candidates_cnk2.pgn -rw-r--r-- 1 nicos nicos 8396 Jan 31 13:09 ../data/pgn/18.03-candidates_cnk3.pgn -rw-r--r-- 1 nicos nicos 7170 Jan 31 13:09 ../data/pgn/18.03-candidates_cnk4.pgn -rw-r--r-- 1 nicos nicos 8525 Jan 31 13:09 ../data/pgn/18.03-candidates_cnk5.pgn -rw-r--r-- 1 nicos nicos 4488 Jan 31 13:09 ../data/pgn/18.03-candidates_cnk6.pgn
> u pgn_chunks.pl lichess_elite_2023-01.pgn stack_limit=12 > u pgn_chunks.pl lichess_elite_2023-02.pgn stack_limit=8 % Setting stack limit to: 8000000000 % Option selected: games(100000). % Starting enumeration of list: inputs % 1.lichess_elite_2023-02.pgn % Ended enumeration of list: inputs % Doing: lichess_elite_2023-02.pgn % Length of sections: 535014 % Parts: 3 % Writing on: 'lichess_elite_2023-02_cnk1.pgn' % Writing on: 'lichess_elite_2023-02_cnk2.pgn' % Writing on: 'lichess_elite_2023-02_cnk3.pgn' % Finished: pgn_chunks