24 lines
594 B
Python
Executable File
24 lines
594 B
Python
Executable File
#!/usr/bin/python2
|
|
|
|
## Country Code Lookup Library
|
|
## Import the CSV file for the country codes
|
|
def openCSV(filename):
|
|
try:
|
|
CSVFile = open(filename)
|
|
return CSVFile
|
|
except Exception as e:
|
|
print(e)
|
|
|
|
def parseCSV(inputFile):
|
|
codeDict = {}
|
|
FileContents = inputFile.read()
|
|
SepContents = FileContents.split('\n')
|
|
#SepContents = FileContents.split(',')
|
|
for entry in SepContents:
|
|
testentry = entry.split(',')
|
|
if len(testentry) == 2:
|
|
codeDict[testentry[1]] = testentry[0]
|
|
else:
|
|
pass
|
|
return codeDict
|