-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelper_Functions.py
84 lines (80 loc) · 3.16 KB
/
helper_Functions.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
__author__ = 's3525116'
#-----------------------------------------------------------------------------------------------------------------------
def extractMemberId(inputString):
memberID = ""
for char in inputString:
if char !='[' and char != "'" and char != ",":
memberID = memberID + char
return memberID
#-----------------------------------------------------------------------------------------------------------------------
def extractMemberName(inputString):
memberName = ""
for char in inputString:
if char !='[' and char != "'" and char != "]" and char != ",":
memberName = memberName + char
elif char == "," or char == "'" or char == '"':
memberName = memberName + " "
return memberName
#-----------------------------------------------------------------------------------------------------------------------
def getLocation(inputString):
memberLocation = ""
for char in inputString:
if char !='(' and char != ")" and char != "," and char !='[' and char !=']':
memberLocation = memberLocation + char
elif char == "," or char == "'" or char == '"':
memberLocation = memberLocation + " "
return memberLocation
#-----------------------------------------------------------------------------------------------------------------------
def RepresentsInt(inputString):
print("inputString")
print(inputString)
nSize = len(inputString)
counter = 0
newInt = -1
comboInt = ""
for char in inputString:
if char.isdigit():
counter = counter + 1
comboInt = comboInt + char
print("counter")
print(counter)
print("nSize")
print(nSize)
if counter == nSize - 3 and counter != 0:
newInt = int(comboInt)
else:
newInt = -1
return newInt
#-----------------------------------------------------------------------------------------------------------------------
def RepresentsIntVersion2(inputString):
nSize = len(inputString)
counter = 0
newInt = -1
comboInt = ""
for char in inputString:
if char.isdigit():
counter = counter + 1
comboInt = comboInt + char
if counter == nSize and counter != 0:
newInt = int(comboInt)
else:
newInt = -1
return newInt
#-----------------------------------------------------------------------------------------------------------------------
def extractString(inputString):
memberID = ""
for char in inputString:
if char !='[' and char != "'" and char != ",":
memberID = memberID + char
return memberID
#-----------------------------------------------------------------------------------------------------------------------
def contains(allReviews, filter):
for x in allReviews:
if filter(x):
return True
return False
#-----------------------------------------------------------------------------------------------------------------------
def loseLastChar(inputString):
result = inputString[:-1]
return result
#-----------------------------------------------------------------------------------------------------------------------