Full library done, should be no bugs (I hope)

This commit is contained in:
Benjamyn Love 2018-03-29 04:48:27 +11:00
parent c0b7f38521
commit b64429ba5c
4 changed files with 21 additions and 3 deletions

3
README.md Normal file
View 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
View File

@ -1,7 +1,23 @@
#!/usr/bin/python2 #!/usr/bin/python2
## Country Code Lookup Library ## Country Code Lookup Library
## Import the CSV file for the country codes ## 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

BIN
cc.pyc Normal file

Binary file not shown.

View File

@ -247,4 +247,3 @@ Western Sahara,EH
Yemen,YE Yemen,YE
Zambia,ZM Zambia,ZM
Zimbabwe,ZW Zimbabwe,ZW

1 Afghanistan AF
247 Yemen YE
248 Zambia ZM
249 Zimbabwe ZW