Skip to content

Instantly share code, notes, and snippets.

@omargfh
Created June 24, 2021 13:15
Show Gist options
  • Save omargfh/9b2208d4cf38000e2d52433f272ae065 to your computer and use it in GitHub Desktop.
Save omargfh/9b2208d4cf38000e2d52433f272ae065 to your computer and use it in GitHub Desktop.
essentially a csv.dictwriter() with a string output, takes in a list of dictionaries and returns the values separated by commas
import re
def dictwriter(dict_list, delimiter=",", end="\n"):
return re.sub(",,", "", end.join([delimiter.join(items) for items in [list([str(v) for (k,v) in list_item.items()]) for list_item in dict_list]]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment