예제 #1
0
def getFileNames():
    if len(sys.argv) > 2:
        inName = sys.argv[1]
        outName = sys.argv[2]
    else:
        inName = utils.getFileName('Enter the name of the log file : ')
        outName = utils.getNewFileName('Enter name of the new file for output : ')
    return inName, outName
예제 #2
0
    indexed by username with value country
    """
    retDict = {}
    for [country, username] in cfile:
        retDict[username] = country
    return retDict

if __name__ == '__main__':
    if len(sys.argv) > 3:
        cFileName = sys.argv[1]
        userFileName = sys.argv[2]
        lName = sys.argv[3]
    else:
        cFileName = utils.getFileName('Name of user name to country file : ')
        userFileName = utils.getFileName('Name of user file : ')
        clName = utils.getNewFileName('Name of class for the output file : ')

    cfile = csv.reader(open(cFileName, 'r'))
    nameDict = buildNameCountry(cfile)
    ufile = csv.reader(open(userFileName, 'r'))
    userDict = user.builddict(ufile)


    clfName = clName + '_id_country.csv'
    outfile = csv.writer(open(clfName, 'w'))

    users = userDict.keys()

    outfile.writerow(['User id', 'Country'])
    for u in users:
        userName = userDict[u].username
예제 #3
0
    """
    retDict = {}
    for [country, username] in cfile:
        retDict[username] = country
    return retDict


if __name__ == '__main__':
    if len(sys.argv) > 3:
        cFileName = sys.argv[1]
        userFileName = sys.argv[2]
        lName = sys.argv[3]
    else:
        cFileName = utils.getFileName('Name of user name to country file : ')
        userFileName = utils.getFileName('Name of user file : ')
        clName = utils.getNewFileName('Name of class for the output file : ')

    cfile = csv.reader(open(cFileName, 'r'))
    nameDict = buildNameCountry(cfile)
    ufile = csv.reader(open(userFileName, 'r'))
    userDict = user.builddict(ufile)

    clfName = clName + '_id_country.csv'
    outfile = csv.writer(open(clfName, 'w'))

    users = userDict.keys()

    outfile.writerow(['User id', 'Country'])
    for u in users:
        userName = userDict[u].username
        if (userName in nameDict):