Created
July 29, 2024 12:14
Uno script per modificare il delimitatore dei file CSV (da virgola a punto e virgola).
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 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