Skip to content

Instantly share code, notes, and snippets.

@theodore-s-beers
Last active June 25, 2023 21:05
Show Gist options
  • Save theodore-s-beers/8423f619dc1538a8829151943a17995a to your computer and use it in GitHub Desktop.
Save theodore-s-beers/8423f619dc1538a8829151943a17995a to your computer and use it in GitHub Desktop.
Convert a TSV file to CSV
with open("table.tsv", "r") as tsv_file:
with open("table.csv", "w") as csv_file:
for line in tsv_file:
# In my most recent use case, replacing commas with colons was suitable
new_line = line.replace(",", ":").replace("\t", ",")
csv_file.write(new_line)
print("Successfully converted to CSV")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment