<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import csv
from time import time
from os.path import join, splitext
from . import _package_root
from .util import Directory

def build(chp_csv_name):

    chp_csv_path = join(_package_root, chp_csv_name)
    db_path = splitext(chp_csv_path)[0]+'.db'

    csv_f = open(chp_csv_path)
    next(csv_f)

    dir_ = Directory(db_path)

    dir_.create_tables()
    for row in csv.reader(csv_f):
        dir_.put(
            ''.join(row[1:-1]).decode('utf-8'),
            row[-1].decode('utf-8'),
            row[0].decode('utf-8'),
        )

    dir_.commit()
    csv_f.close()

if __name__ == '__main__':

    try:
        import clime.now
    except ImportError:
        import sys
        build(*sys.argv[1:])
<commit_msg>added msgs<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import csv
from time import time
from os.path import join, splitext
from . import _package_root
from .util import Directory

def build(chp_csv_name):

    print 'Building the ZIP code index ...',
    sys.stdout.flush()

    chp_csv_path = join(_package_root, chp_csv_name)
    db_path = splitext(chp_csv_path)[0]+'.db'

    csv_f = open(chp_csv_path)
    next(csv_f)

    dir_ = Directory(db_path)

    dir_.create_tables()
    for row in csv.reader(csv_f):
        dir_.put(
            ''.join(row[1:-1]).decode('utf-8'),
            row[-1].decode('utf-8'),
            row[0].decode('utf-8'),
        )

    dir_.commit()
    csv_f.close()

    print 'done.'

if __name__ == '__main__':

    try:
        import clime.now
    except ImportError:
        import sys
        build(*sys.argv[1:])

{'fraction_non_alphanumeric': 0.14122596153846154, 'fraction_numerical': 0.01201923076923077, 'mean_word_length': 2.46875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6160844', 'n_tokens_mistral': 621, 'n_tokens_neox': 591, 'n_words': 124}