Skip to content

Instantly share code, notes, and snippets.

@LouisdeBruijn
Last active December 31, 2020 10:52
Show Gist options
  • Select an option

  • Save LouisdeBruijn/cb7de6ed434a41cf2a83211bdb819c7c to your computer and use it in GitHub Desktop.

Select an option

Save LouisdeBruijn/cb7de6ed434a41cf2a83211bdb819c7c to your computer and use it in GitHub Desktop.
data = [
("Hi my name is Louis, and I write compound sentences, often delimited by a comma.", "26", "de Bruijn")
]
with open("texts.csv", "w") as csv_out:
for element in data:
csv_out.write("{0}\n".format(",".join(element)))
objects = []
with open("texts.csv", "r") as csv_in:
for line in csv_in:
line = line.rstrip().split(",")
objects.append(line)
print(objects)
>>> [['Hi my name is Louis', ' and I write compound sentences', ' often delimited by a comma.', '26', 'de Bruijn']]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment