def run(*args): df = pd.read_csv(os.path.join(CURRENT_DIR, FILE_NAME), parse_dates=['Date']) print(df.info()) print(df.head()) for i in range(len(districts)): dis = District(name=districts[i + 1]['name'], ) print(dis) dis.save() for index, row in df.iterrows(): print(index) se = SeaTurtleCount( district=dis, date=row['Date'].to_pydatetime(), value=row['sea_turtle_count'], ) print(se) se.save()
def insert_data(files): from app.models import Region, District dist, reg = get_file(files) for item in range(1, len(dist)): regions = Region.objects.get(id=int(reg[item])) dis = District(region=regions, district_name=dist[item].lower()) dis.save()