FILUM
File Utilities
FILUM
is a C++ library which
handles information in text files.
The original version of this library used the C representation of strings as
pointers to characters. The library is being updated to use the C++ string
data type.
Licensing:
The computer code and data files described and made available on this web page
are distributed under
the GNU LGPL license.
Languages:
FILUM is available in
a C version and
a C++ version and
a FORTRAN77 version and
a FORTRAN90 version and
a Mathematica version and
a MATLAB version and
a Python version.
Related Data and Programs:
CR2LF,
a C++ program which
reads a text file and replaces carriage returns by line feeds.
CRRM,
a C++ program which
reads a text file and removes the carriage return character.
DEBLANK,
a C++ program which
reads a text file and writes a copy which has no blank lines.
DECOMMENT,
a C++ program which
makes a copy of a text file which contains no "comment" lines
(that begin with "#").
DETROFF,
a C++ program which
removes from a file every occurrence of the TROFF overprint
pair character+backspace, which can make a MAN page printable;
FILE_NAME_SEQUENCE,
a C++ program which
demonstrates ways to generate a sequence of filenames
that can be used when generating images for an animation.
REFORMAT,
a FORTRAN90 program which
makes a copy of a file with a given number of "words" per line.
REWORD,
a C++ program which
reads a text file and writes a copy which has a fixed number
of "words" per line.
UNCONTROL,
a C++ program which
makes a copy of a text file which contains no control characters.
WRAP,
a C++ program which
makes a copy of a text file
in which no line is longer than a user-specified wrap length.
Reference:
-
Tom Christiansen, Nathan Torkington,
"8.6: Picking a Random Line from a File",
Perl Cookbook, pages 284-285,
O'Reilly, 1999.
Source Code:
Examples and Tests:
Files used for some of the tests include:
-
filum_prb_4by5.txt, a file with
missing right parentheses.
-
filum_prb_test.txt, a sample file.
-
filum_prb_append.txt, an
example of FILE_APPEND.
-
filum_prb_braces.txt, a file
with balanced and legal braces.
-
filum_prb_columns.txt, a file
of 4 rows and 5 columns of numeric data.
-
filum_prb_copy.txt, an example of
FILE_COPY.
-
filum_prb_reverse_columns.txt,
an example of FILE_REVERSE_COLUMNS.
-
filum_prb_parens1.txt, a file
with missing right parentheses.
-
filum_prb_parens2.txt, a file
with illegally occurring right parentheses.
-
filum_prb_parens3.txt, a file
with balanced and legal parentheses.
-
filum_prb_reverse_rows.txt,
an example of FILE_REVERSE_ROWS.
-
story.txt,
a file containing a title line and 5 paragraphs of text.
DATA_***.TXT is a short sequence of three files, each having 8 data
items, 3 on the first line, 3 on the second, and 2 on the third line,
to be examined by FILE_SEQUENCE_SIZE.
List of Routines:
-
CH_CAP capitalizes a single character.
-
CH_EQI is true if two characters are equal, disregarding case.
-
CH_IS_DIGIT returns TRUE if a character is a decimal digit.
-
CH_LOW lowercases a single character.
-
CH_TO_DIGIT returns the integer value of a base 10 digit.
-
CH_TO_ROT13 converts a character to its ROT13 equivalent.
-
DIGIT_INC increments a decimal digit.
-
DIGIT_TO_CH returns the base 10 digit character corresponding to a digit.
-
FILE_CHAR_COUNT counts the number of characters in a file.
-
FILE_COLUMN_COUNT counts the columns in the first line of a file.
-
FILE_DELETE deletes a named file if it exists.
-
FILE_EXIST reports whether a file exists.
-
FILE_LINE_UNIFORM returns a random line from a file.
-
FILE_LINE_WIDTH reports the length of the longest line in a file.
-
FILE_PARA_COUNT counts the number of paragraphs in a file.
-
FILE_ROW_COUNT counts the number of row records in a file.
-
FILE_SEQUENCE_DELETE deletes a file sequence.
-
FILE_SEQUENCE_SIZE sizes a file sequence.
-
FILE_WORD_COUNT counts the number of words in a file.
-
FILENAME_DEC decrements a partially numeric file name.
-
FILENAME_EXT_GET determines the "extension" of a file name.
-
FILENAME_EXT_SWAP replaces the current "extension" of a file name.
-
FILENAME_INC increments a partially numeric file name.
-
FILENAME_INC_NOWRAP increments a partially numeric file name.
-
I4_MAX returns the maximum of two I4's.
-
I4_MIN returns the smaller of two I4's.
-
I4_UNIFORM returns a scaled pseudorandom I4.
-
NUMBER_INC increments the integer represented by a string.
-
R4_ABS returns the absolute value of an R4.
-
R4_NINT returns the nearest integer to an R4.
-
R8_NINT returns the nearest integer to an R8.
-
R8_UNIFORM_01 returns a unit pseudorandom R8.
-
S_EQI reports whether two strings are equal, ignoring case.
-
S_LEN_TRIM returns the length of a string to the last nonblank.
-
S_LOW lowercases a string.
-
S_REVERSE reverses the characters in a string.
-
S_TO_I4 reads an I4 from a string.
-
S_TO_I4VEC reads an I4VEC from a string.
-
S_TO_R8 reads an R8 from a string.
-
S_TO_R8VEC reads an R8VEC from a string.
-
S_TO_ROT13 "rotates" the characters in a string by 13 positions.
-
S_WORD_COUNT counts the number of "words" in a string.
-
TIMESTAMP prints the current YMDHMS date as a time stamp.
You can go up one level to
the C++ source codes.
Last revised on 22 November 2011.