pandas-dev / pandas

Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more
https://pandas.pydata.org
BSD 3-Clause "New" or "Revised" License
43.65k stars 17.92k forks source link

Google analytics error with eventLabel and totalEvents #2983

Closed rippedathlete closed 10 years ago

rippedathlete commented 11 years ago

pandas 0.10.1, on OSX mountain lion, installed through pip.

So, this works fine for me,

events = ga.read_ga(['visits'],
                dimensions=["date"],
                start_date='2013-01-15',

                secrets=secretsfile,
                account_name="******************",
                property_id="***************")

But when I do the following,

events = ga.read_ga(['totalEvents'],
                dimensions=["eventLabel"],
                start_date='2013-01-15',

                secrets=sec,
                account_name="Ripped Athlete",
                property_id="UA-37875661-1")

I get this traceback (abbreviated)

/usr/local/lib/python2.7/site-packages/pandas/io/ga.pyc in _parse_data(self, rows, col_info, index_col, parse_dates, keep_date_col, date_parser, dayfirst, na_values, converters, sort)
    309                                   keep_date_col=keep_date_col,
    310                                   converters=converters,
--> 311                                   header=None, names=col_names))
    312 
    313         if isinstance(sort, bool) and sort:

/usr/local/lib/python2.7/site-packages/pandas/io/parsers.pyc in _read(filepath_or_buffer, kwds)
    206 
    207     # Create the parser.
--> 208     parser = TextFileReader(filepath_or_buffer, **kwds)
    209 
    210     if nrows is not None:

/usr/local/lib/python2.7/site-packages/pandas/io/parsers.pyc in __init__(self, f, engine, **kwds)
    505             self.options['has_index_names'] = kwds['has_index_names']
    506 
--> 507         self._make_engine(self.engine)
    508 
    509     def _get_options_with_defaults(self, engine):

/usr/local/lib/python2.7/site-packages/pandas/io/parsers.pyc in _make_engine(self, engine)
    613             elif engine == 'python-fwf':
    614                 klass = FixedWidthFieldParser
--> 615             self._engine = klass(self.f, **self.options)
    616 
    617     def _failover_to_python(self):

/usr/local/lib/python2.7/site-packages/pandas/io/parsers.pyc in __init__(self, f, **kwds)
   1157         else:
   1158             self.data = f
-> 1159         self.columns = self._infer_columns()
   1160 
   1161         # get popped off for index

/usr/local/lib/python2.7/site-packages/pandas/io/parsers.pyc in _infer_columns(self)
   1331                 line = self.buf[0]
   1332             else:
-> 1333                 line = self._next_line()
   1334 
   1335             ncols = len(line)

/usr/local/lib/python2.7/site-packages/pandas/io/parsers.pyc in _next_line(self)
   1352                 line = self.data[self.pos]
   1353             except IndexError:
-> 1354                 raise StopIteration
   1355         else:
   1356             while self.pos in self.skiprows:

StopIteration: 

Before I dig in further, I noticed that PythonParser._infer_columns doesn't handle the StopIteration that can be raised by PythonParser._next_line. Should we consider raising that exception to be normal operation and change _infer_columns to handle it, or should we figure out what strange mix of circumstances is causing _next_iteration to raise it?

jreback commented 10 years ago

closing as stale