TABLE_COLUMNS
Extract a column from a file.


TABLE_COLUMNS is a FORTRAN90 program which extracts specified columns of data from a text file.

The file is presumed to consist of lines of data. Blank lines are ok, and are copied to the output file. Lines beginning with a '#' in column 1 are treated as comments, and are copied to the output file.

Each line of data contains several words, separated by one or more spaces or TAB characters. The first word in each line is the first "column", and so on. TABLE_COLUMNS is given a specificiation of which columns are to be copied, in what order, and how often, and copies the necessary information from each line of the input file to the output file.

The specification of columns is simple. You can simply list every column you want, separated by spaces, or if there are several consecutive columns in a row, you can use a colon to indicate a range.

The program can be used in command line form:

table_columns column_spec filein fileout
or can be invoked interactively with no arguments, in which case the program will request information from the user.

For example, let us suppose that file.txt contains the lines:

        CAT RED   APPLE 9.5
        MOUSE  BLUE   ORANGE 
        DOG purple  Banana   34.7
      

Then the command

table_columns 2 file.txt mydata.txt
will copy the following data into mydata.txt:
        RED
        BLUE
        purple
      

The command

table_columns 2 3 2 file.txt mydata.txt
will create the file:
        RED APPLE RED
        BLUE ORANGE BLUE
        purple Banana purple
      

The command

table_columns 2:4 2 2 file.txt mydata.txt
will create the file:
        RED   APPLE 9.5 RED RED
        BLUE   ORANGE *** BLUE BLUE
        purple  Banana   34.7 purple purple
      

If some lines of the file do not have the full number of columns, then the program will print a "***" string for that value, which occurred in the last example above.

Licensing:

The computer code and data files made available on this web page are distributed under the GNU LGPL license.

Languages:

TABLE_COLUMNS is available in a FORTRAN90 version.

Related Data and Programs:

FILE_COLUMN_REVERSE, a FORTRAN90 program which creates a copy of a file in which the columns are reverse, that is, the characters on each line appear in reverse order.

REVERSE_COLUMNS, a FORTRAN90 program which creates a copy of a file in which the columns are reverse, that is, the characters on each line appear in reverse order.

FILE_TRANSPOSE, a FORTRAN90 program which makes a "transposed" copy of a file, in which the I-th "word" of the J-th line becomes the J-th word of the I-th line.

TABLE_BARPLOT_PPMA, a FORTRAN90 program which reads a table file and creates an ASCII PPM bargraph of the data.

TABLE_BORDER, a FORTRAN90 program which adds a border (of zero values) to a table file.

TABLE_COLUMNS_PERMUTE, a FORTRAN90 program which permutes the columns of a table file.

TABLE_DELAUNAY, a FORTRAN90 program which computes the Delaunay triangulation of a set of points.

TABLE_HISTOGRAM, a FORTRAN90 program which makes a histogram of a set of points stored in a table file.

TABLE_IO, a FORTRAN90 library which supplies the routines used to read the TABLE file.

TABLE_LATINIZE, a FORTRAN90 program which reads a file of points and creates a "latinized" version by adjusting the data.

TABLE_MERGE, a FORTRAN90 program which reads a file of points, and removes duplicates, and points that are close to each other.

TABLE_ORTHONORMALIZE, a FORTRAN90 program which reads a file of points and orthonormalizes the columns.

TABLE_QUALITY, a FORTRAN90 program which reads a file of points and computes the quality of dispersion.

TABLE_RECORD_MATCH, a FORTRAN90 program which finds close records in a table file.

TABLE_SCALE, a FORTRAN90 program which multiplies the entries of a table file by a scale vector.

TABLE_SHIFT, a FORTRAN90 program which shifts the entries of a table file by a shift vector.

TABLE_STATS, a FORTRAN90 program which reads a table file and compute certain statistics.

TABLE_TET_MESH, a FORTRAN90 program which reads a table file of 3D data, and compute a tetrahedral mesh.

TABLE_TOP, a FORTRAN90 program which reads a table file of M-dimensional data and make a table of plots of all pairs of coordinates.

TABLE_UNBORDER, a FORTRAN90 program which removes the border from a table file.

TABLE_UNIFORM_NOISE, a FORTRAN90 program which adds a uniform noise term to the data in a table file.

TABLE_VORONOI, a FORTRAN90 program which computes information about the Voronoi diagram of points stored in a table file.

Source Code:

Examples and Tests:

List of Routines:

You can go up one level to the FORTRAN90 source codes.


Last revised on 18 August 2010.