Run2 CSV Reporting

Reliable CSV generation for security audits with automated field mapping.

cxcscmu Updated

File contents

Reliable CSV Reporting

This skill focuses on clean and error-free CSV generation.

Best Practices

  • Use csv.DictWriter for clarity and automatic field alignment.
  • Always specify newline='' when opening the file to avoid blank lines on some platforms.
  • Ensure all dictionary keys match the fieldnames list exactly.
import csv

def generate_csv_report(data_list, output_file):
    if not data_list:
        print("No data to write to CSV.")
        return

    fieldnames = list(data_list[0].keys())
    with open(output_file, 'w', newline='', encoding='utf-8') as f:
        writer = csv.DictWriter(f, fieldnames=fieldnames)
        writer.writeheader()
        writer.writerows(data_list)

cxcscmu/SkillLearnBench commit 6ad3c2b222

Frequently asked questions

npx get-skill add cxcscmu/run2-csv-reporting-2