0

Given the following models:

class Stream(models.Model):
    name = models.CharField(max_length=32)
    label = models.CharField(max_length=32)
    ...

class Data(models.Model):
    class Meta:
        ordering = ['timestamp']
    timestamp = models.DateTimeField(db_index=True)  # in UTC !
    data = models.FloatField()
    stream = models.ForeignKey(to=Stream, editable=False)
    ...

I need to output results in the following (CSV) format:

Example output:

Timestamp,A,B,C,D
2017/03/03:00:01:00,4,2,1.9,3
2017/03/03:00:01:15,4,3,1.8.3
...

A,B,C and D are streams labels.

Values are from Data.data field.

chaim
  • 1,236
  • 2
  • 14
  • 16
  • Possible duplicate question: http://stackoverflow.com/questions/41585078/how-do-i-read-and-write-csv-files-with-python – vonBerg Apr 23 '17 at 16:46
  • It's not a duplicate of that question, I have no problem with reading or writing CSV, only with the transform section. – chaim Apr 23 '17 at 16:48

0 Answers0