Full library done, should be no bugs (I hope)
This commit is contained in:
parent
c0b7f38521
commit
b64429ba5c
3
README.md
Normal file
3
README.md
Normal file
@ -0,0 +1,3 @@
|
||||
This is a quick library that I threw together to translate contry codes to there full name
|
||||
|
||||
This is only meant for internal projects so lol rip
|
||||
20
cc.py
Normal file → Executable file
20
cc.py
Normal file → Executable file
@ -1,7 +1,23 @@
|
||||
#!/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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user