How to use the agate.Table.from_csv function in agate

To help you get started, we’ve selected a few agate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wireservice / agate / tests / test_table / __init__.py View on Github external
def test_from_csv_sniff_limit(self):
        table1 = Table(self.rows, self.column_names, self.column_types)
        table2 = Table.from_csv('examples/test_csv_sniff.csv', sniff_limit=None)

        self.assertColumnNames(table2, table1.column_names)
        self.assertColumnTypes(table2, [Number, Text, Boolean, Date, DateTime, TimeDelta])

        self.assertRows(table2, table1.rows)
github wireservice / agate / tests / test_table / __init__.py View on Github external
def test_from_csv(self):
        table1 = Table(self.rows, self.column_names, self.column_types)
        table2 = Table.from_csv('examples/test.csv')

        self.assertColumnNames(table2, table1.column_names)
        self.assertColumnTypes(table2, [Number, Text, Boolean, Date, DateTime, TimeDelta])

        self.assertRows(table2, table1.rows)
github wireservice / agate / tests / test_table / __init__.py View on Github external
def test_from_csv_skip_lines_sequence(self):
        table1 = Table([self.rows[1]], column_names=self.column_names, column_types=self.column_types)
        table2 = Table.from_csv('examples/test.csv', skip_lines=(1, 3))

        self.assertColumnNames(table2, table1.column_names)
        self.assertColumnTypes(table2, [Number, Text, Boolean, Date, DateTime, TimeDelta])

        self.assertRows(table2, table1.rows)
github wireservice / agate / tests / test_table / __init__.py View on Github external
def test_from_csv_no_header(self):
        table = Table.from_csv('examples/test_no_header.csv', header=False)

        self.assertColumnNames(table, ['a', 'b', 'c', 'd', 'e', 'f'])
        self.assertColumnTypes(table, [Number, Text, Boolean, Date, DateTime, TimeDelta])
github wireservice / agate / tests / test_table.py View on Github external
def test_from_csv(self):
        table1 = Table(self.rows, self.column_names, self.column_types)
        table2 = Table.from_csv('examples/test.csv')

        self.assertColumnNames(table2, table1.column_names)
        self.assertColumnTypes(table2, [Number, Text, Boolean, Date, DateTime, TimeDelta])

        self.assertRows(table2, table1.rows)
github wireservice / agate / tests / test_table / test_from_csv.py View on Github external
def test_from_csv_no_header_columns(self):
        table = Table.from_csv('examples/test_no_header.csv', self.column_names, header=False)

        self.assertColumnNames(table, self.column_names)
        self.assertColumnTypes(table, [Number, Text, Boolean, Date, DateTime, TimeDelta])
github wireservice / agate / tests / test_table / __init__.py View on Github external
def test_from_csv_type_tester(self):
        tester = TypeTester(force={
            'number': Text()
        })

        table = Table.from_csv('examples/test.csv', column_types=tester)

        self.assertColumnTypes(table, [Text, Text, Boolean, Date, DateTime, TimeDelta])
github wireservice / agate / charts.py View on Github external
#!/usr/bin/env python

import agate


table = agate.Table.from_csv('examples/realdata/Datagov_FY10_EDU_recp_by_State.csv')

table.limit(10).bar_chart('State Name', 'TOTAL', 'docs/images/bar_chart.svg')
table.limit(10).column_chart('State Name', 'TOTAL', 'docs/images/column_chart.svg')

table = agate.Table.from_csv('examples/realdata/exonerations-20150828.csv')

by_year_exonerated = table.group_by('exonerated')
counts = by_year_exonerated.aggregate([
    ('count', agate.Count())
])

counts.order_by('exonerated').line_chart('exonerated', 'count', 'docs/images/line_chart.svg')
table.scatterplot('exonerated', 'age', 'docs/images/dots_chart.svg')

top_crimes = table.group_by('crime').having([
    ('count', agate.Count())
], lambda t: t['count'] > 100)

by_year = top_crimes.group_by('exonerated')

counts = by_year.aggregate([
github wireservice / agate / exonerations.py View on Github external
def load_data(data):
    data['exonerations'] = agate.Table.from_csv('examples/realdata/exonerations-20150828.csv')

    print(data['exonerations'])
github polygraph-cool / last-two-minute-report / custom / incorrect-call.py View on Github external
'play_id': agate.Text(),
    'away': agate.Text(),
    'home': agate.Text(),
    'date': agate.Text(),
    'ref_1': agate.Text(),
    'ref_2': agate.Text(),
    'ref_3': agate.Text(),
    'score_away': agate.Number(),
    'score_home': agate.Number(),
    'original_pdf': agate.Text(),
    'box_score_url': agate.Text(),
    'committing_team': agate.Text(),
    'disadvantaged_team': agate.Text()
}

data = agate.Table.from_csv('../.tmp/concat.csv', column_types=specified_types)

select_columns = ['play_id', 'ref_1', 'ref_2', 'ref_3', 'video', 'box_score_url', 'original_pdf', 'game_id']

ic = data.where(lambda r: r['review_decision'] == 'IC').select(select_columns)

ic.to_csv('incorrect_call.csv')