Skip to content

Instantly share code, notes, and snippets.

@gioxx
Created July 29, 2024 12:14
Show Gist options
  • Save gioxx/01b0bb9b5d27c8c227486182193df00b to your computer and use it in GitHub Desktop.
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).
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