The Transposer

The Transposer will read in a text file with delimited data in rows and columns and transpose the rows into columns. This can be used to take TRIM files which list the Compartments across the top as columns and create a file with Compartments as rows. For example, the Transposer can take this file as input:

Date;       Time;     Zone; Compartment_1; Compartment_2; Compartment_3;
01/01/1990; 00:00:00;  EST;     1.298E-03;     3.865E-05;     5.670E-07;
01/01/1990; 01:00:00;  EST;     1.409E-03;     3.986E-05;     5.832E-07;
01/01/1990; 02:00:00;  EST;     1.682E-03;     4.279E-05;     5.855E-07;
01/01/1990; 03:00:00;  EST;     1.800E-03;     4.553E-05;     5.878E-07;

And turn it into a file like this:

Date;          01/01/1990; 01/01/1990; 01/01/1990; 01/01/1990;
Time;            00:00:00;   01:00:00;   02:00:00;   03:00:00;
Zone;                 EST;        EST;        EST;        EST;
Compartment_1;  1.298E-03;  1.409E-03;  1.682E-03;  1.800E-03;
Compartment_2;  3.865E-05;  3.986E-05;  4.279E-05;  4.553E-05;
Compartment_3;  5.670E-07;  5.832E-07;  5.855E-07;  5.878E-07; 

The Transposer is currently limited to handling files that will fit into you computer's memory. Later version will support transposing larger files. This means that you must determine the amount of memory in your computer before handling large files.

The Transposer is run from the DOS or UNIX command line using the following options:

Option Required? Description

-i

Y

The name of the input file that you would like to transpose.

-o

Y

The name of the output file to which the results are written.

-d

N

The delimiter between columns (default is semicolon).

For example, to read in the file "stream_data.txt" and output the file "stream_data_2.txt" with semi-colons as delimiters, type:

java gov.epa.trim.util.Transposer -i stream_data.txt -o stream_data_2.txt -d ";"

If you have a large file, you may need to specify more memory. This is done as an option to the Java program as follows:

for 64MB of memory  -Xmx64m

for 128MB of memory  -Xmx128m

for 256MB of memory  -Xmx256m

for 512MB of memory  -Xmx512m

For example, to transpose a file of size 400MB on a computer that has at least 512MB of memory, type:

java -Xmx512m gov.epa.trim.util.Transposer -i stream_data.txt -o stream_data_2.txt