<commit_before>from django.core.management.base import BaseCommand
from openpyxl import load_workbook

from pharmacotherapy.models import Drugs


class Command(BaseCommand):
    def add_arguments(self, parser):
        """
        :param path - файл с кодами МКБ10.2019 + расшифровка
        """
        parser.add_argument('path', type=str)

    def handle(self, *args, **kwargs):
        fp = kwargs["path"]
        self.stdout.write("Path: " + fp)
        wb = load_workbook(filename=fp)
        ws = wb[wb.sheetnames[0]]
        print(ws)
        starts = False
        mnn, torg = '', ''
        for row in ws.rows:
            cells = [str(x.value) for x in row]
            if not starts:
                if "мнн" in cells and "торг" in cells:
                    starts = True
                    torg = cells.index("торг")
                    mnn = cells.index("мнн")
            else:
                print(cells[mnn])
                if cells[mnn] == "~":
                    continue
                Drugs.objects.create(mnn=cells[mnn][:255], trade_name=cells[torg][:255])
                print(f'добавлен МНН:{cells[mnn]}:{cells[torg]}')
<commit_msg>fix var-name<commit_after>from django.core.management.base import BaseCommand
from openpyxl import load_workbook

from pharmacotherapy.models import Drugs


class Command(BaseCommand):
    def add_arguments(self, parser):
        """
        :param path - файл с мнн + торговое наименование
        """
        parser.add_argument('path', type=str)

    def handle(self, *args, **kwargs):
        fp = kwargs["path"]
        self.stdout.write("Path: " + fp)
        wb = load_workbook(filename=fp)
        ws = wb[wb.sheetnames[0]]
        print(ws)
        starts = False
        mnn, trade_name = '', ''
        for row in ws.rows:
            cells = [str(x.value) for x in row]
            if not starts:
                if "мнн" in cells and "торг" in cells:
                    starts = True
                    trade_name = cells.index("торг")
                    mnn = cells.index("мнн")
            else:
                print(cells[mnn])
                if cells[mnn] == "~":
                    continue
                Drugs.objects.create(mnn=cells[mnn][:255], trade_name=cells[trade_name][:255])
                print(f'добавлен МНН:{cells[mnn]}:{cells[trade_name]}')

{'fraction_non_alphanumeric': 0.12196162046908315, 'fraction_numerical': 0.008528784648187633, 'mean_word_length': 1.7995226730310263, 'pattern_counts': {'":': 2, '<': 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': '4733437', 'n_tokens_mistral': 763, 'n_tokens_neox': 717, 'n_words': 159}