I want to process a tab-delimited input data file with header and generate a tab-delimited output file according to a template.
Here is a small setting:
Data file:
A B C
1 4 7
2 5 8
3 6 9
Template file that defines columns in the output:
A:A
BC:B+C
HC:C/2, precision:2
The template file contains these operations: creation of a new column, summation and division operations on columns, and definition of precision of rational numbers in a column.
Output file:
A BC HC
1 11 3.50
2 13 4.00
3 15 4.50
Where can I start to write an interpreter in python? The interpreter will parse the template file, and then output data will be generated using the input data according to this parsed template file.
+, '/', andprecisionthe only possible operators in a template file? Are there any rules for the template grammar that are not shown in the example?