Created
September 10, 2021 10:42
-
-
Save InputBlackBoxOutput/4550e02272aa474b1d89d377a9cb318b to your computer and use it in GitHub Desktop.
Python program for changing the delimiter of a CSV file
This file contains hidden or 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, sys | |
input_file ="input.csv" | |
output_file ="output.csv" | |
input_file_delimiter = ';' | |
output_file_delimiter = ',' | |
output = [] | |
with open(input_file) as f_input: | |
lines = f_input.read().splitlines() | |
for each_line in lines: | |
output.append(re.sub(input_file_delimiter, output_file_delimiter, each_line)) | |
with open(output_file, 'w') as f_output: | |
for each in output: | |
f_output.write(each + '\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment