Created
July 29, 2024 12:14
-
-
Save gioxx/01b0bb9b5d27c8c227486182193df00b to your computer and use it in GitHub Desktop.
Uno script per modificare il delimitatore dei file CSV (da virgola a punto e virgola).
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 csv | |
import sys | |
if len(sys.argv) != 3: | |
print("Utilizzo: python script.py input_file.csv output_file.csv") | |
sys.exit(1) | |
input_file = sys.argv[1] | |
output_file = sys.argv[2] | |
# Leggi il file CSV con separatori virgola | |
with open(input_file, 'r') as file: | |
reader = csv.reader(file) | |
data = list(reader) | |
# Scrivi il nuovo file CSV con separatori punto e virgola | |
with open(output_file, 'w', newline='') as file: | |
writer = csv.writer(file, delimiter=';') | |
writer.writerows(data) | |
print(f"Conversione completata. File di output: {output_file}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment