-
Notifications
You must be signed in to change notification settings - Fork 1
/
lectureMenu.py
46 lines (31 loc) · 1.17 KB
/
lectureMenu.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
# -*- coding: utf-8 -*-
import lectureTXT
import lectureCSV
def readOrWrite():
"""Menu that asks the user if he wants to read a file or edit one """
print("Souhaitez-vous ouvrir ou éditer un fichier?")
print("1. Ouvrir")
print("2. Editer")
print("3. Quitter")
return input("\nChoix : ")
def writeFileName():
"""Get the file chosen by the user to be opened """
print("Tapez le nom du fichier que vous souhaitez ouvrir")
return input("\nNom du fichier : ")
def whichFileType(fileName):
"""Search which type of file has been selected by the user """
typeList = ["csv", "txt", "pdf"]
lowerFileName = fileName.lower()
for fileType in typeList:
if lowerFileName.find(fileType) != -1:
return fileType
def readFile(fileChosen, fileType):
"""Return a list of the elements read in a specific type of file """
fileChosen = fileChosen.lower()
print(fileChosen)
if fileType == "csv":
return lectureCSV.fileCSVToList(fileChosen)
elif fileType == "txt":
return lectureTXT.fileTXTToList(fileChosen)
else:
print("Le fichier n'a pu être trouvé")