#!/usr/bin/env python

import sys

import agate

from csvkit.cli import CSVKitUtility


class CSVPy(CSVKitUtility):
    description = 'Load a CSV file into a CSV reader and then drop into a Python shell.'

    def add_arguments(self):
        self.argparser.add_argument('--dict', dest='as_dict', action='store_true',
                                    help='Load the CSV file into a DictReader.')
        self.argparser.add_argument('--agate', dest='as_agate', action='store_true',
                                    help='Load the CSV file into an agate table.')

    def main(self):
        if self.input_file == sys.stdin:
            self.argparser.error('csvpy cannot accept input as piped data via STDIN.')

        # Attempt reading filename, will cause lazy loader to access file and raise error if it does not exist
        filename = self.input_file.name

        if self.args.as_dict:
            klass = agate.csv.DictReader
            class_name = 'agate.csv.DictReader'
            variable_name = 'reader'
        elif self.args.as_agate:
            klass = agate.Table.from_csv
            class_name = 'agate.Table'
            variable_name = 'table'
        else:
            klass = agate.csv.reader
            class_name = 'agate.csv.reader'
            variable_name = 'reader'

        variable = klass(self.input_file, **self.reader_kwargs)

        welcome_message = 'Welcome! "{}" has been loaded in an {} object named "{}".'.format(
            filename, class_name, variable_name)

        try:
            from IPython.frontend.terminal.embed import InteractiveShellEmbed
            exec(f'{variable_name} = variable')
            ipy = InteractiveShellEmbed(banner1=welcome_message)
            ipy()
        except ImportError:
            import code
            code.interact(welcome_message, local={variable_name: variable})


def launch_new_instance():
    utility = CSVPy()
    utility.run()


if __name__ == '__main__':
    launch_new_instance()

5f1f1e3a3139082e47f62a67185b2d7d075209a7
<mask token>


class CSVPy(CSVKitUtility):
    description = (
        'Load a CSV file into a CSV reader and then drop into a Python shell.')

    def add_arguments(self):
        self.argparser.add_argument('--dict', dest='as_dict', action=
            'store_true', help='Load the CSV file into a DictReader.')
        self.argparser.add_argument('--agate', dest='as_agate', action=
            'store_true', help='Load the CSV file into an agate table.')

    def main(self):
        if self.input_file == sys.stdin:
            self.argparser.error(
                'csvpy cannot accept input as piped data via STDIN.')
        filename = self.input_file.name
        if self.args.as_dict:
            klass = agate.csv.DictReader
            class_name = 'agate.csv.DictReader'
            variable_name = 'reader'
        elif self.args.as_agate:
            klass = agate.Table.from_csv
            class_name = 'agate.Table'
            variable_name = 'table'
        else:
            klass = agate.csv.reader
            class_name = 'agate.csv.reader'
            variable_name = 'reader'
        variable = klass(self.input_file, **self.reader_kwargs)
        welcome_message = (
            'Welcome! "{}" has been loaded in an {} object named "{}".'.
            format(filename, class_name, variable_name))
        try:
            from IPython.frontend.terminal.embed import InteractiveShellEmbed
            exec(f'{variable_name} = variable')
            ipy = InteractiveShellEmbed(banner1=welcome_message)
            ipy()
        except ImportError:
            import code
            code.interact(welcome_message, local={variable_name: variable})


<mask token>

<mask token>


class CSVPy(CSVKitUtility):
    description = (
        'Load a CSV file into a CSV reader and then drop into a Python shell.')

    def add_arguments(self):
        self.argparser.add_argument('--dict', dest='as_dict', action=
            'store_true', help='Load the CSV file into a DictReader.')
        self.argparser.add_argument('--agate', dest='as_agate', action=
            'store_true', help='Load the CSV file into an agate table.')

    def main(self):
        if self.input_file == sys.stdin:
            self.argparser.error(
                'csvpy cannot accept input as piped data via STDIN.')
        filename = self.input_file.name
        if self.args.as_dict:
            klass = agate.csv.DictReader
            class_name = 'agate.csv.DictReader'
            variable_name = 'reader'
        elif self.args.as_agate:
            klass = agate.Table.from_csv
            class_name = 'agate.Table'
            variable_name = 'table'
        else:
            klass = agate.csv.reader
            class_name = 'agate.csv.reader'
            variable_name = 'reader'
        variable = klass(self.input_file, **self.reader_kwargs)
        welcome_message = (
            'Welcome! "{}" has been loaded in an {} object named "{}".'.
            format(filename, class_name, variable_name))
        try:
            from IPython.frontend.terminal.embed import InteractiveShellEmbed
            exec(f'{variable_name} = variable')
            ipy = InteractiveShellEmbed(banner1=welcome_message)
            ipy()
        except ImportError:
            import code
            code.interact(welcome_message, local={variable_name: variable})


def launch_new_instance():
    utility = CSVPy()
    utility.run()


<mask token>

<mask token>


class CSVPy(CSVKitUtility):
    description = (
        'Load a CSV file into a CSV reader and then drop into a Python shell.')

    def add_arguments(self):
        self.argparser.add_argument('--dict', dest='as_dict', action=
            'store_true', help='Load the CSV file into a DictReader.')
        self.argparser.add_argument('--agate', dest='as_agate', action=
            'store_true', help='Load the CSV file into an agate table.')

    def main(self):
        if self.input_file == sys.stdin:
            self.argparser.error(
                'csvpy cannot accept input as piped data via STDIN.')
        filename = self.input_file.name
        if self.args.as_dict:
            klass = agate.csv.DictReader
            class_name = 'agate.csv.DictReader'
            variable_name = 'reader'
        elif self.args.as_agate:
            klass = agate.Table.from_csv
            class_name = 'agate.Table'
            variable_name = 'table'
        else:
            klass = agate.csv.reader
            class_name = 'agate.csv.reader'
            variable_name = 'reader'
        variable = klass(self.input_file, **self.reader_kwargs)
        welcome_message = (
            'Welcome! "{}" has been loaded in an {} object named "{}".'.
            format(filename, class_name, variable_name))
        try:
            from IPython.frontend.terminal.embed import InteractiveShellEmbed
            exec(f'{variable_name} = variable')
            ipy = InteractiveShellEmbed(banner1=welcome_message)
            ipy()
        except ImportError:
            import code
            code.interact(welcome_message, local={variable_name: variable})


def launch_new_instance():
    utility = CSVPy()
    utility.run()


if __name__ == '__main__':
    launch_new_instance()

import sys
import agate
from csvkit.cli import CSVKitUtility


class CSVPy(CSVKitUtility):
    description = (
        'Load a CSV file into a CSV reader and then drop into a Python shell.')

    def add_arguments(self):
        self.argparser.add_argument('--dict', dest='as_dict', action=
            'store_true', help='Load the CSV file into a DictReader.')
        self.argparser.add_argument('--agate', dest='as_agate', action=
            'store_true', help='Load the CSV file into an agate table.')

    def main(self):
        if self.input_file == sys.stdin:
            self.argparser.error(
                'csvpy cannot accept input as piped data via STDIN.')
        filename = self.input_file.name
        if self.args.as_dict:
            klass = agate.csv.DictReader
            class_name = 'agate.csv.DictReader'
            variable_name = 'reader'
        elif self.args.as_agate:
            klass = agate.Table.from_csv
            class_name = 'agate.Table'
            variable_name = 'table'
        else:
            klass = agate.csv.reader
            class_name = 'agate.csv.reader'
            variable_name = 'reader'
        variable = klass(self.input_file, **self.reader_kwargs)
        welcome_message = (
            'Welcome! "{}" has been loaded in an {} object named "{}".'.
            format(filename, class_name, variable_name))
        try:
            from IPython.frontend.terminal.embed import InteractiveShellEmbed
            exec(f'{variable_name} = variable')
            ipy = InteractiveShellEmbed(banner1=welcome_message)
            ipy()
        except ImportError:
            import code
            code.interact(welcome_message, local={variable_name: variable})


def launch_new_instance():
    utility = CSVPy()
    utility.run()


if __name__ == '__main__':
    launch_new_instance()

#!/usr/bin/env python

import sys

import agate

from csvkit.cli import CSVKitUtility


class CSVPy(CSVKitUtility):
    description = 'Load a CSV file into a CSV reader and then drop into a Python shell.'

    def add_arguments(self):
        self.argparser.add_argument('--dict', dest='as_dict', action='store_true',
                                    help='Load the CSV file into a DictReader.')
        self.argparser.add_argument('--agate', dest='as_agate', action='store_true',
                                    help='Load the CSV file into an agate table.')

    def main(self):
        if self.input_file == sys.stdin:
            self.argparser.error('csvpy cannot accept input as piped data via STDIN.')

        # Attempt reading filename, will cause lazy loader to access file and raise error if it does not exist
        filename = self.input_file.name

        if self.args.as_dict:
            klass = agate.csv.DictReader
            class_name = 'agate.csv.DictReader'
            variable_name = 'reader'
        elif self.args.as_agate:
            klass = agate.Table.from_csv
            class_name = 'agate.Table'
            variable_name = 'table'
        else:
            klass = agate.csv.reader
            class_name = 'agate.csv.reader'
            variable_name = 'reader'

        variable = klass(self.input_file, **self.reader_kwargs)

        welcome_message = 'Welcome! "{}" has been loaded in an {} object named "{}".'.format(
            filename, class_name, variable_name)

        try:
            from IPython.frontend.terminal.embed import InteractiveShellEmbed
            exec(f'{variable_name} = variable')
            ipy = InteractiveShellEmbed(banner1=welcome_message)
            ipy()
        except ImportError:
            import code
            code.interact(welcome_message, local={variable_name: variable})


def launch_new_instance():
    utility = CSVPy()
    utility.run()


if __name__ == '__main__':
    launch_new_instance()
