Last active
April 23, 2017 18:24
-
-
Save orf/a63091f93154844bfd8d32a510945da3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = open('test.csv', 'w') | |
stream_labels = list(Stream.objects.order_by('label').values_list('label', flat=True)) | |
x.write('Timestamp,' + ','.join(stream_labels) + '\n') | |
for timestamp in Data.objects.values_list('timestamp', flat=True): | |
data_values = Data.objects.filter(timestamp=timestamp, stream__label__in=stream_labels).order_by('stream__label).values_list('data', flat=True) | |
x.write(str(timestamp) + ',' + ','.join(data_values) + '\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment