<commit_before>#! /usr/bin/env python

# Usage: ./load.py /path/to/DC_MasterFile_79930.mvl

import sys

from ipeds_importer.models import Variable

path = sys.argv[1]

print path
print Variable.objects.count()

with open(path, "r") as f:
    for row in f:
        bits = row.split('|')
        code, short_name, category, long_name = bits[0:4]
        data = dict(code=code,
                    short_name=short_name,
                    category=category,
                    long_name=long_name)
        Variable.objects.get_or_create(raw=row, defaults=data)
print Variable.objects.count()<commit_msg>assign a stripped down version of the code<commit_after>#! /usr/bin/env python

# Usage: ./load.py /path/to/DC_MasterFile_79930.mvl

import re
import sys

from ipeds_importer.models import Variable

path = sys.argv[1]

print path
print Variable.objects.count()

with open(path, "r") as f:
    for row in f:
        bits = row.split('|')
        code, short_name, category, long_name = bits[0:4]
        code = re.match(r'([a-zA-Z]+)', code).groups()[0]
        data = dict(code=code,
                    short_name=short_name,
                    category=category,
                    long_name=long_name)
        Variable.objects.get_or_create(raw=row, defaults=data)
print Variable.objects.count()
{'fraction_non_alphanumeric': 0.11895625479662318, 'fraction_numerical': 0.013046815042210284, 'mean_word_length': 2.6022099447513813, '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': '6388051', 'n_tokens_mistral': 444, 'n_tokens_neox': 423, 'n_words': 97}