Spaces:
Sleeping
Sleeping
| import csv | |
| # Nama file input dan output | |
| input_file = "dataset.csv" | |
| output_file = "cleaned_dataset.csv" | |
| # Bersihkan dataset | |
| with open(input_file, "r") as infile, open(output_file, "w", newline="") as outfile: | |
| reader = csv.reader(infile) | |
| writer = csv.writer(outfile) | |
| # Periksa setiap baris | |
| for row in reader: | |
| # Hanya simpan baris dengan 2 kolom | |
| if len(row) == 2: | |
| writer.writerow(row) | |
| print(f"Dataset telah dibersihkan. Simpan ke: {output_file}") | |