Ejemplo n.º 1
0
        i += 1

    # 6. Convert to the form "Letter, Digit, Digit, Digit" by adding trailing zeros
    #    (if there are fewer than three digits) or by dropping rightmost digits if
    #    there are more than three).
    s = s[0] + k[0:3] + ('0' * (3 - len(k)))
    return s


# By default, try to establish names that collide, testing the algorithms.
if __name__ == '__main__':
    import oplcsv
    import sys

    csv = oplcsv.Csv(sys.argv[1])
    nameidx = csv.index('Name')
    names = [r[nameidx] for r in csv.rows]

    h = {}
    counts = {}

    for name in names:
        comps = name.split()[0:2]
        if len(comps) != 2:
            continue

        if not comps[0].isalpha() or len(comps[0]) <= 1:
            continue
        if not comps[1].isalpha() or len(comps[1]) <= 1:
            continue
Ejemplo n.º 2
0
    return s


# By default, try to establish names that collide, testing the algorithms.
if __name__ == '__main__':
    import oplcsv
    import os

    # Build an index of Names.
    names = []
    for dirname, subdirs, files in os.walk(os.getcwd()):
        if 'meet-data' in subdirs:
            subdirs[:] = ['meet-data']
        if 'entries.csv' in files:
            filepath = dirname + os.sep + 'entries.csv'
            csv = oplcsv.Csv(filepath)
            nameidx = csv.index('Name')
            names += [r[nameidx] for r in csv.rows]

    h = {}
    counts = {}

    for name in names:
        comps = name.split()[0:2]
        if len(comps) != 2:
            continue

        if not comps[0].isalpha() or len(comps[0]) <= 1:
            continue
        if not comps[1].isalpha() or len(comps[1]) <= 1:
            continue
Ejemplo n.º 3
0
def standardize_country_filename(filename):
    csv = oplcsv.Csv(filename)
    if standardize_country_csv(csv):
        csv.write_filename(filename)