Create a shorter version of a file containing sections by skimming the first N sections.
Uses io_section/3 and not io_sections/3, so can be used as an example of incrementally working through
sections of a file.
Opts
- debug(Dbg=true)
- informational, progress messages
- ext(Ext)
- extension to use for output (InFile's is used if missing)
- help(Help=false)
- help messsage and exit
- in_file(InFile)
- input file
- nos(Nos)
- number of sections
- os_sep(Sep=_)
- separator for postfix see os_postfix/3
- out_separator(Out)
- output section separator (codes list)- needs to be present if
separator() is not
- stem(Stem)
- if one given it is used as the baename of the file (with same ext as InFile)
- postfix(Psfx = <Sep>f<Nos>)
- if Stem is not given use Psfx to create output file from InFile
- usage(Usg=false)
- usage message and exit
Also all the options accepted by io_section_open/3.
Examples
?- head_sections( [in_file(pack('stoics_lib/examples/sectioned.txt')),stem(ex_sec_2),nos(2),separator(`[term]`)] ).
% This produces a file with 4 lines, 2 setions, first of which is empty.
- author
- - nicos angelopoulos
- version
- - 0.1 2025/12/19