def issue_to_dict(issue):
    """
    Convert an issue to a dictionary suitable for outputting to csv
    """
    issue_data = {}
    issue_data['id'] = issue.id
    issue_data['title'] = issue.title
    issue_data['description'] = issue.description
    issue_data['due_date'] = issue.due_date
    issue_data['labels'] = '; '.join(issue.labels) if len(issue.labels) > 0 else ''
    issue_data['web_url'] = issue.web_url
    issue_data['author'] = issue.author.name
    issue_data['assignees'] = '; '.join([a['name'] for a in issue.assignees]) if len(issue.labels) > 0 else ''
    issue_data['last_updated'] = issue.updated_at
    issue_data['state'] = issue.state
    if issue.milestone:
        issue_data['milestone'] = issue.milestone.title
        issue_data['milestone_duedate'] = issue.milestone.due_date
    return issue_data