-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput.py
34 lines (28 loc) · 845 Bytes
/
input.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import interfaces
import pandas as pd
class CSVInput(interfaces.Input):
def __init__(self):
self.namafile = "input.csv"
def filetidakada(self):
pesan = f"File {self.namafile} tidak ditemukan!"
print(pesan)
def open(self):
try:
df = pd.read_csv(self.namafile)
return df
except FileNotFoundError as fileerror:
self.filetidakada()
return []
class CSVConfig(interfaces.Input):
def __init__(self):
self.namafile = "config.csv"
def filetidakada(self):
pesan = f"File {self.namafile} tidak ditemukan!"
print(pesan)
def open(self):
try:
df = pd.read_csv(self.namafile)
return df
except FileNotFoundError as fileerror:
self.filetidakada()
return []