Created
June 24, 2021 13:15
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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