nursinghomes.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:correctiv-nursinghomes 作者: correctiv 项目源码 文件源码
def load_supervision_authorities(self, *args, **options):
        excel_file = pd.ExcelFile(options['filename'])
        state_names = excel_file.sheet_names

        for state_name in state_names:
            state = State.objects.get(name=state_name)
            df = excel_file.parse(state_name)
            for _, row in df.iterrows():
                try:
                    email = stringify(row['email'])
                    if email:
                        email = email.splitlines()[0]
                        email = EMAIL_RE.search(email)
                        email = email.group(0).strip() if email is not None else ''
                        email = email.lower()
                    authority, created = SupervisionAuthority.objects.update_or_create(
                        state=state, name=stringify(row['name']), defaults=dict(
                            address=stringify(row['address']),
                            contact=stringify(row['contact']),
                            email=email,
                            url=stringify(row['url']),
                            report_url=stringify(row.get(u'Verfügbare Berichte', ''))
                        )
                    )
                    if created:
                        print(authority)
                except Exception:
                    print(row['name'])
                    raise
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号