table_columns, a Fortran90 code 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 fileoutor 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.txtwill copy the following data into mydata.txt:
RED BLUE purple
The command
table_columns 2 3 2 file.txt mydata.txtwill create the file:
RED APPLE RED BLUE ORANGE BLUE purple Banana purple
The command
table_columns 2:4 2 2 file.txt mydata.txtwill 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.
The information on this web page is distributed under the MIT license.
table_columns is available in a Fortran90 version.
table_io, a Fortran90 code which supplies the routines used to read the TABLE file.
table_quality, a Fortran90 code which reads a file of points and computes the quality of dispersion.
table_top, a Fortran90 code which reads a table file of M-dimensional data and make a table of plots of all pairs of coordinates.