We needed to add 100+ bugs to our FogBugz database today, and I figured it would be easier to write a tool to import them than to enter them all by hand. Thank goodness for the FogBugz XML API and the Python library.
This tool reads from a CSV file (with header row) and adds the case via the API.
Example CSV data:
Category,Title,Project,Assigned To,Priority,Status,Milestone
Feature,"Report is incorrect",Website,Unassigned,3 - Very Important,Active,Product Backlog
Feature,"Login fails",Website,me@website.com,3 - Very Important,Active,Product Backlog
Feature,"Logo is incorrect",Website,Unassigned,3 - Very Important,Active,Product Backlog
import csv
import sys
import os
from fogbugz import FogBugz
if len(sys.argv) < 5:
sys.exit("Usage: python fbInportCSV.py <URL> <USER> <PASSWORD> <CSV FILE>")
# Make sure the CSV file exists
if not os.path.exists(sys.argv[4]):
sys.exit('ERROR: CSV file %s was not found!' % sys.argv[4])
fburl = sys.argv[1]
fbuser = sys.argv[2]
fbpass = sys.argv[3]
csvfile = sys.argv[4]
# Connect to FogBugz server
fb = FogBugz(fburl)
fb.logon(fbuser, fbpass)
# For each row, print key data and add to FogBugz
with open(csvfile, 'rb') as csvfile:
csvreader = csv.DictReader(csvfile)
for row in csvreader:
print "Adding:"
print " Title : " + row["Title"]
print " Project : " + row["Project"]
print " Category : " + row["Category"]
print " Milestone : " + row["Milestone"]
print "======================="
fb.new(sTitle=row["Title"],
sProject=row["Project"],
sCategory=row["Category"],
sFixFor=row["Milestone"]
)