I am building the transformation logic for a file that applies certain transformation rules on the fields in the file. Example of such transformation rules are:

* Setting default values for certain fields if they are empty (if col 5 is empty, set it to "Empty")
* Summarizing the file based on certain columns (if file has col1, col2 and col3, summarize file to aggregate col3 for all col1)
* Substituting strings in certain fields (replace all "ax" in col1 with "ay")
* Etc.

From a performance perspective, when dealing with performing these transformations on a large file, is it better to do it using plain file processing (read file line by line, use hashes for summarizing, regexes for other transformations etc.) or load the data into a database table, summarize and apply all transform logic and download it back to a file?

Eg of summarization:

Original file has:

A|B|C|100|200|300

A|B|C|200|100|0

A|X|C|100|100|100

Transformed file has:

A|B|300|300|300

A|X|100|100|100