|
|
|
|
@ -6,11 +6,9 @@ from geojson import MultiPolygon
|
|
|
|
|
from tqdm import tqdm
|
|
|
|
|
|
|
|
|
|
from service import models
|
|
|
|
|
from service.enums import PointStatus
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def load_data(filepath: str):
|
|
|
|
|
statuses = {point.value: point.name for point in PointStatus}
|
|
|
|
|
models.PlacementPoint.objects.all().delete()
|
|
|
|
|
df = pd.read_csv(filepath)
|
|
|
|
|
df = df.replace(np.nan, None)
|
|
|
|
|
@ -18,11 +16,8 @@ def load_data(filepath: str):
|
|
|
|
|
for row in tqdm(df.to_dict('records'), desc='Loading data...'):
|
|
|
|
|
data = {
|
|
|
|
|
k: row[k] for k in row.keys() if
|
|
|
|
|
k not in ['id', 'status', 'location_id', 'okrug', 'rayon', 'age_month']
|
|
|
|
|
k not in ['id', 'location_id', 'area', 'district', 'age_month']
|
|
|
|
|
}
|
|
|
|
|
data['status'] = statuses[row['status']]
|
|
|
|
|
data['okrug'] = models.AO.objects.get(name=row['okrug'])
|
|
|
|
|
data['rayon'] = models.Rayon.objects.get(name=row['rayon'])
|
|
|
|
|
models.PlacementPoint.objects.create(**data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|