Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,15 +1,18 @@
|
|
| 1 |
-
import pandas as pd
|
| 2 |
-
from sklearn.feature_extraction.text import CountVectorizer
|
| 3 |
-
from sklearn.naive_bayes import MultinomialNB
|
| 4 |
-
import gradio as gr
|
| 5 |
import csv
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
except FileNotFoundError:
|
| 11 |
-
data = {"pertanyaan": [], "jawaban": []}
|
| 12 |
-
df = pd.DataFrame(data)
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import csv
|
| 2 |
|
| 3 |
+
# Nama file input dan output
|
| 4 |
+
input_file = "dataset.csv"
|
| 5 |
+
output_file = "cleaned_dataset.csv"
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
# Bersihkan dataset
|
| 8 |
+
with open(input_file, "r") as infile, open(output_file, "w", newline="") as outfile:
|
| 9 |
+
reader = csv.reader(infile)
|
| 10 |
+
writer = csv.writer(outfile)
|
| 11 |
+
|
| 12 |
+
# Periksa setiap baris
|
| 13 |
+
for row in reader:
|
| 14 |
+
# Hanya simpan baris dengan 2 kolom
|
| 15 |
+
if len(row) == 2:
|
| 16 |
+
writer.writerow(row)
|
| 17 |
+
|
| 18 |
+
print(f"Dataset telah dibersihkan. Simpan ke: {output_file}")
|