MRT3216 / roboscout_2016

A full suite of tools to collect and analyze FRC game data for the 2016 competition (Stronghold) [very much a WIP, please help]
5 stars 3 forks source link

Added a python file to export a csv from the database #1

Closed adamsong closed 8 years ago

adamsong commented 8 years ago

For the teams who would like this data as a spreadsheet this script will dump the matches table as a csv to stdout.

vampjaz commented 8 years ago

I'll merge this tomorrow when I push some of my local changes.

ArchdukeTim commented 8 years ago

Why not print to a csv file?

vampjaz commented 8 years ago

Here's an idea for more concise code that does print to a csv:

import os,sys,sqlite3
from config import *

conn = sqlite3.connect(DATABASE)
c = conn.cursor()
fd = open('data_dump.csv')

print ','.join(row[1] for row in c.execute('PRAGMA table_info(matches)'))
fd.write(','.join(row[1] for row in c.execute('PRAGMA table_info(matches)')) + '\n')

for row in c.execute('SELECT * FROM matches'):
    print ','.join(row)
    fd.write(','.join(row) + '\n')

fd.close()
ArchdukeTim commented 8 years ago

pls merge. Kinda want this