Skip to content

Instantly share code, notes, and snippets.

@641i130
Created March 24, 2025 17:32
Show Gist options
  • Select an option

  • Save 641i130/3f794b890d42f791085c044b77a86cc5 to your computer and use it in GitHub Desktop.

Select an option

Save 641i130/3f794b890d42f791085c044b77a86cc5 to your computer and use it in GitHub Desktop.

Revisions

  1. 641i130 created this gist Mar 24, 2025.
    27 changes: 27 additions & 0 deletions convert.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    #!/usr/bin/env python3

    import csv
    import sys

    # Check if an input file is provided
    if len(sys.argv) < 2:
    print("Usage: python convert_to_gitlab.py <input_csv_file>")
    sys.exit(1)

    input_file = sys.argv[1]
    output_file = f"{input_file}_gitlab.csv"

    # Read the input CSV and write to output in GitLab format
    with open(input_file, newline='', encoding='utf-8') as csvfile, open(output_file, 'w', newline='', encoding='utf-8') as outfile:
    reader = csv.DictReader(csvfile)
    writer = csv.writer(outfile)

    # Write the header
    writer.writerow(["title", "description"])

    for row in reader:
    title = row.get("Summary", "").strip()
    if title: # Ensure title is not empty
    writer.writerow([title, title])

    print(f"Conversion complete. Output saved to {output_file}")