From 58be8c72f8dc25ffe4d7dffa511f0f2f7da64215 Mon Sep 17 00:00:00 2001 From: Akira Date: Sun, 15 Feb 2026 14:12:50 +0900 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=AE=8C=E4=BA=86=20backend/?= =?UTF-8?q?apps/fields/views.py=20=E3=82=92=E4=BF=AE=E6=AD=A3=E3=81=97?= =?UTF-8?q?=E3=81=BE=E3=81=97=E3=81=9F=EF=BC=9A=20=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E5=86=85=E5=AE=B9=201.=20=E5=85=B1=E6=B8=88=E3=83=9E=E3=82=B9?= =?UTF-8?q?=E3=82=BF=E5=8F=96=E8=BE=BC=20(import=5Fkyosai=5Fmaster)=20-=20?= =?UTF-8?q?k=5Fnum=20=E2=86=92=20=E8=80=95=E5=9C=B0=E7=95=AA=E5=8F=B7=20-?= =?UTF-8?q?=20s=5Fnum=20=E2=86=92=20=E5=88=86=E7=AD=86=E7=95=AA=E5=8F=B7?= =?UTF-8?q?=20-=20address=20=E2=86=92=20=E5=9C=B0=E5=90=8D=20=E5=9C=B0?= =?UTF-8?q?=E7=95=AA=20-=20kanji=5Fname=20=E2=86=92=20=E6=BC=A2=E5=AD=97?= =?UTF-8?q?=E5=9C=B0=E5=90=8D=20-=20area=20=E2=86=92=20=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E9=9D=A2=E7=A9=8D(m2)=202.=20=E5=AE=9F=E5=9C=83=E5=A0=B4?= =?UTF-8?q?=E3=83=87=E3=83=BC=E3=82=BF=E5=8F=96=E8=BE=BC=20(import=5Fyoshi?= =?UTF-8?q?da=5Ffields)=20-=20name=20=E2=86=92=20=E5=90=8D=E7=A7=B0=20-=20?= =?UTF-8?q?address=20=E2=86=92=20=E4=BD=8F=E6=89=80=20-=20area=5Ftan=20?= =?UTF-8?q?=E2=86=92=20=E9=9D=A2=E7=A9=8D(=E5=8F=8D)=20-=20area=5Fm2=20?= =?UTF-8?q?=E2=86=92=20=E9=9D=A2=E7=A9=8D(=E5=8F=8D)=20*=201000=20(?= =?UTF-8?q?=E8=87=AA=E5=8B=95=E8=A8=88=E7=AE=97)=20-=20owner=5Fname=20?= =?UTF-8?q?=E2=86=92=20=E5=9C=B0=E4=B8=BB=20-=20raw=5Fkyosai=5Fk=5Fnum=20?= =?UTF-8?q?=E2=86=92=20=E7=B4=B0=E7=9B=AE=5F=E8=80=95=E5=9C=B0=E7=95=AA?= =?UTF-8?q?=E5=8F=B7=20-=20raw=5Fkyosai=5Fs=5Fnum=20=E2=86=92=20=E7=B4=B0?= =?UTF-8?q?=E7=9B=AE=5F=E5=88=86=E7=AD=86=E7=95=AA=E5=8F=B7=20-=20raw=5Fch?= =?UTF-8?q?usankan=5Fid=20=E2=86=92=20=E4=B8=AD=E5=B1=B1=E9=96=93=5FID=203?= =?UTF-8?q?.=20=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=9F=E5=A0=85=E7=89=A2?= =?UTF-8?q?=E5=8C=96=20-=20df.columns=20=3D=20df.columns.str.strip()=20?= =?UTF-8?q?=E3=81=A7=E3=82=AB=E3=83=A9=E3=83=A0=E5=90=8D=E3=81=AE=E4=BD=99?= =?UTF-8?q?=E7=99=BD=E3=82=92=E9=99=A4=E5=8E=BB=20=E3=83=90=E3=83=83?= =?UTF-8?q?=E3=82=AF=E3=82=A8=E3=83=B3=E3=83=89=E3=82=92=E5=86=8D=E8=B5=B7?= =?UTF-8?q?=E5=8B=95=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F=E3=80=82=E5=86=8D?= =?UTF-8?q?=E5=BA=A6=E3=82=A4=E3=83=B3=E3=83=9D=E3=83=BC=E3=83=88=E3=82=92?= =?UTF-8?q?=E5=AE=9F=E8=A1=8C=E3=81=97=E3=81=A6=E3=81=BF=E3=81=A6=E3=81=8F?= =?UTF-8?q?=E3=81=A0=E3=81=95=E3=81=84=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/apps/fields/views.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/backend/apps/fields/views.py b/backend/apps/fields/views.py index ba17b6b..e7bd8cb 100644 --- a/backend/apps/fields/views.py +++ b/backend/apps/fields/views.py @@ -24,22 +24,23 @@ def import_kyosai_master(request): try: df = pd.read_excel(ods_file, engine='odf') + df.columns = df.columns.str.strip() created_count = 0 updated_count = 0 for _, row in df.iterrows(): - k_num = str(row.get('k_num', '')).strip() if pd.notna(row.get('k_num')) else '' - s_num = str(row.get('s_num', '')).strip() if pd.notna(row.get('s_num')) else '' + k_num = str(row.get('耕地番号', '')).strip() if pd.notna(row.get('耕地番号')) else '' + s_num = str(row.get('分筆番号', '')).strip() if pd.notna(row.get('分筆番号')) else '' if not k_num: continue defaults = { 's_num': s_num, - 'address': str(row.get('address', '')).strip() if pd.notna(row.get('address')) else '', - 'kanji_name': str(row.get('kanji_name', '')).strip() if pd.notna(row.get('kanji_name')) else '', - 'area': float(row.get('area', 0)) if pd.notna(row.get('area')) else 0, + 'address': str(row.get('地名 地番', '')).strip() if pd.notna(row.get('地名 地番')) else '', + 'kanji_name': str(row.get('漢字地名', '')).strip() if pd.notna(row.get('漢字地名')) else '', + 'area': float(row.get('本地面積(m2)', 0)) if pd.notna(row.get('本地面積(m2)')) else 0, } obj, created = OfficialKyosaiField.objects.update_or_create( @@ -73,28 +74,29 @@ def import_yoshida_fields(request): try: df = pd.read_excel(ods_file, engine='odf') + df.columns = df.columns.str.strip() created_count = 0 updated_count = 0 for _, row in df.iterrows(): - name = str(row.get('name', '')).strip() if pd.notna(row.get('name')) else '' + name = str(row.get('名称', '')).strip() if pd.notna(row.get('名称')) else '' if not name: continue - raw_kyosai_k = str(int(row.get('raw_kyosai_k_num', 0))) if pd.notna(row.get('raw_kyosai_k_num')) else None - raw_kyosai_s = str(int(row.get('raw_kyosai_s_num', 0))) if pd.notna(row.get('raw_kyosai_s_num')) else None - raw_chusankan = str(int(row.get('raw_chusankan_id', 0))) if pd.notna(row.get('raw_chusankan_id')) else None + raw_kyosai_k = str(int(row.get('細目_耕地番号', 0))) if pd.notna(row.get('細目_耕地番号')) else None + raw_kyosai_s = str(int(row.get('細目_分筆番号', 0))) if pd.notna(row.get('細目_分筆番号')) else None + raw_chusankan = str(int(row.get('中山間_ID', 0))) if pd.notna(row.get('中山間_ID')) else None - area_tan = float(row.get('area_tan', 0)) if pd.notna(row.get('area_tan')) else 0 - area_m2 = int(row.get('area_m2', 0)) if pd.notna(row.get('area_m2')) else 0 + area_tan = float(row.get('面積(反)', 0)) if pd.notna(row.get('面積(反)')) else 0 + area_m2 = int(area_tan * 1000) if area_tan else 0 defaults = { - 'address': str(row.get('address', '')).strip() if pd.notna(row.get('address')) else '', + 'address': str(row.get('住所', '')).strip() if pd.notna(row.get('住所')) else '', 'area_tan': area_tan, 'area_m2': area_m2, - 'owner_name': str(row.get('owner_name', '')).strip() if pd.notna(row.get('owner_name')) else '', + 'owner_name': str(row.get('地主', '')).strip() if pd.notna(row.get('地主')) else '', 'raw_kyosai_k_num': raw_kyosai_k, 'raw_kyosai_s_num': raw_kyosai_s, 'raw_chusankan_id': raw_chusankan,