-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmCVS.py
48 lines (39 loc) · 975 Bytes
/
mCVS.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/use/bin/python
import csv
'''
Class to handle the CVS files
'''
class CVS(object):
def __init__(self, nameFile,maxValue):
self.nameFile = nameFile
self.maxValue = maxValue
'''
Open the file , skip the header line and get the "reader"
'''
def openFile(self):
# opens the csv file
self.fo = open(self.nameFile, 'rb')
r = 0
# skip header line
while r < 1:
self.fo.next()
r = r + 1
self.reader = csv.reader(self.fo)
'''
From the "reader" return an array
'''
def getArray(self):
arr = []
i = 0
for item in self.reader:
arr.append(item)
i += 1
# from "reader" read at maximum n row
if i >= self.maxValue:
break
return arr
'''
Close the file
'''
def closeFile(self):
self.fo.close()