def dict_to_csv(orig_dict, file_name, field_names_tuple, file_location):
file = __os.path.join(file_location, file_name)<EOL>csv_write = open(file, '<STR_LIT:a>')<EOL>writer = __csv.DictWriter(csv_write, fieldnames=field_names_tuple, lineterminator='<STR_LIT:\n>')<EOL>headers = dict((n, n) for n in field_names_tuple)<EOL>writer.writerow(headers)<EOL>for dict_key, a in list(orig_dict.items()):<EOL><INDENT>writer.writerow(orig_dict[dict_key])<EOL><DEDENT>csv_write.close()<EOL>return file_name<EOL>
Function to export a dictionary to a csv file
Args:
    orig_dict: The dictionary you want exported
    file_name: The name of the exported file
    field_names_tuple: The fieldnames in a tuple
    file_location: The location of the file, derive from the os module

Returns: returns the filename info