-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlezione4.py
More file actions
26 lines (26 loc) · 861 Bytes
/
lezione4.py
File metadata and controls
26 lines (26 loc) · 861 Bytes
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
class CSVfile ():
def __init__ (self, name):
self.name = name
def __str__ (self):
return 'Nome file: {}' .format(self.name)
def get_data (self):
values = []
data = []
my_file = open (self.name)
for line in my_file:
#divido gli elementi in base a dov'è la virgola
elements = line.split(',')
#se la riga non è Date, allora mi salvo il valore in value
if elements[0] != 'Date':
value = elements[1]
values.append(value)
data = elements[0]
values.append(data)
print ("[{}] [{}]" .format (data, value[0: -1]))
elif elements[0] == 'Date':
print ("{}" .format(elements))
my_file.close
fily = CSVfile("shampoo_sales.csv")
print (fily)
print (fily.name)
fily.get_data()