Adhoc Kit
Workflows

awk script example for CSV processing

03
CSV report

Sum a column in a CSV file

You have a CSV export with many rows and need a total for one column. Adhoc Kit writes an awk script, runs it, and shows the result.

01

Open folder

Open the project folder in Adhoc Kit.

02

Write script

Create report.awk with the logic.

03

Run command

Execute awk -f report.awk data.csv in WSL or over SSH.

04

Check result

Review the output and exit code.

The report.awk file

report.awk
# report.awk
# Calculate total for field 3
BEGIN { FS = "," }
NR == 1 { next }
{
  total += $3
  count++
}
END {
  printf "Rows: %d\n", count
  printf "Total: %.2f\n", total
}

This short program skips the header line, adds the third field to a running total, and prints the final count and sum when the file ends. Note that a plain comma separator breaks on CSV fields that contain quoted commas.

awk field separator not working with regex

Write the script

Adhoc Kit uses write_file to create report.awk in your working folder and the agent runs the command in the Shell tool to process your data. You see the output. The program skips the first line using NR == 1. It adds the third field to the total variable for calculation. The END block prints the results for your review and analysis. You can ask how to perform an awk inplace update just one field in your workflow. Check the exit code to confirm that awk ran successfully. Verify the total against the data for accuracy and correctness.

Review the output

The Shell tool returns the printed text so you see the row count and the total sum from the agent clearly, and Adhoc Kit records this action for your review. You approve. You can use this method for any CSV file that you need to process. You split string in awk with delimiter to handle complex data structures. The regex tutorial helps you understand field splitting logic deeply. You test the pattern on sample lines first to verify correctness. Adhoc Kit runs the command again if you change the script logic. You use Ask first mode before proceeding with the update.

Adhoc Kit for Windows

Start processing your files

Download Adhoc Kit ↗