Last active
June 25, 2023 21:05
-
-
Save theodore-s-beers/8423f619dc1538a8829151943a17995a to your computer and use it in GitHub Desktop.
Convert a TSV file to CSV
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
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