def test_facet(self): "Facet tables based on shared column values" t = TableFu(self.csv_file) tables = t.facet_by('Style') style_row = self.table[4] self.assertEqual( style_row, tables[2][0].cells )
def testFacets(self): table = Table(self.yml) options = self.parsed['table']['column_options'] url = "http://spreadsheets.google.com/pub?key=tcSL0eqrj3yb5d6ljak4Dcw&output=csv" response = urllib2.urlopen(url) tf = TableFu(response, **options) tables = tf.facet_by('State') for i, t in enumerate(tables): self.assertEqual(t.table, table.data[i].table)
def _open(self): if self.url: f = urllib2.urlopen(self.url) elif self.filename: f = open(self.filename, 'rb') else: # there's neither a url nor a file raise TableError("You must specify a google_key, URL or local file containing CSV data") t = TableFu(f, **self.options.get('column_options', {})) if self.options.get('faceting', False): return t.facet_by(self.options['faceting']['facet_by']) return t