# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-05-07 01:42
from __future__ import unicode_literals

from django.db import migrations
from django.contrib.auth.models import User
import csv


def get_rater(apps, schema_editor):
    Rater = apps.get_model("ratings", "Rater")
    with open('../ml-100k/u.user', 'r') as f:
        data = csv.reader(f, delimiter='|')
        count = 0
        for row in data:
            user = User.objects.Create(username='stacy' + str(count), email='email' + str(count) + '@gmail.com', password='password')
            count += 1
            rater = Rater(age=row[1], gender=row[2], occupation=row[3], user=user)
            rater.save()

class Migration(migrations.Migration):

    dependencies = [
        ('ratings', '0001_initial'),
    ]

    operations = [
        migrations.RunPython(get_rater),
    ]
