How to extract data from a Django QuerySet

0

I have a table with some information, the name of the employee, pis, date and time, the time field records the time of the record in the point clock, these records are all in the same column, for example: Employee 1, has four check in, check in, check in, check in, check in, check in, check in, check in, check in, check in, check in, check in, check in, check in, check in, check in, check in, check in, check in, field.

If anyone can logically help with this implementation, I'm grateful. It may even be also before importing the CSV file, because this data is imported to from a CSV but just the way it is. If I can do this even before import, it will resolve.

    
asked by anonymous 21.11.2016 / 21:24

1 answer

0

In importing the file you could do something like this:

Assuming your model has all the fields quoted above and the file has the following format: name, pee, schedule1, schedule2, schedule3, schedule4.

for line in file.readlines():
    data = line.split(',')
    funcionario = Funcionario(nome=data[0], pis=data[1], horario1=data[3] ...)
    funcionario.save()
    
22.11.2016 / 18:39