我使用Python从Adwords下载一些报告,然后使用pandas重新格式化数据。
import pandas as pd
from googleads import adwords
stream_data = downloader.DownloadReportWithAwql(
products_query,
'CSV', output_file,
client_customer_id='xxxxx',
skip_report_header=True,
skip_report_summary=True,
skip_column_header=False)
data = pd.read_csv(output_file,
sep=',',
encoding='utf-8-sig',
header=1,
error_bad_lines=False,
warn_bad_lines=False)
print(data)
生成的文件如下所示:
647972293,695588-4,enabled,enabled,1,0.00,2017-04-01,2,50.00%,0.00%,0.00,350000,0.00
647972293,794745-4,enabled,enabled,0,0.00,2017-04-01,5,0.00%,0.00%,0.00,0,0.00
647972293,695882-4,enabled,enabled,0,0.00,2017-04-01,1,0.00%,0.00%,0.00,0,0.00
647972293,798115-4,enabled,enabled,0,0.00,2017-04-01,6,0.00%,0.00%,0.00,0,0.00
647972293,649265-4,enabled,enabled,0,0.00,2017-04-01,4,0.00%,0.00%,0.00,0,0.00
647972293,265195-4,enabled,enabled,0,0.00,2017-04-01,17,0.00%,0.00%,0.00,0,0.00
647972293,115024-4,enabled,enabled,0,0.00,2017-04-01,3,0.00%,0.00%,0.00,0,0.00
647972293,660673-4,enabled,enabled,0,0.00,2017-04-01,1,0.00%,0.00%,0.00,0,0.00
但是,出于某种原因我收到此错误:
Traceback (most recent call last):
File "/Users/nasiantalla/PycharmProjects/adwords_test.py", line 95, in <module>
error_bad_lines=False)
File "/Users/nasiantalla/Library/Python/3.6/lib/python/site-packages/pandas/io/parsers.py", line 646, in parser_f
return _read(filepath_or_buffer, kwds)
File "/Users/nasiantalla/Library/Python/3.6/lib/python/site-packages/pandas/io/parsers.py", line 389, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File "/Users/nasiantalla/Library/Python/3.6/lib/python/site-packages/pandas/io/parsers.py", line 730, in __init__
self._make_engine(self.engine)
File "/Users/nasiantalla/Library/Python/3.6/lib/python/site-packages/pandas/io/parsers.py", line 923, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
File "/Users/nasiantalla/Library/Python/3.6/lib/python/site-packages/pandas/io/parsers.py", line 1390, in __init__
self._reader = _parser.TextReader(src, **kwds)
File "pandas/parser.pyx", line 535, in pandas.parser.TextReader.__cinit__ (pandas/parser.c:6086)
File "pandas/parser.pyx", line 710, in pandas.parser.TextReader._get_header (pandas/parser.c:8843)
File "pandas/parser.pyx", line 911, in pandas.parser.TextReader._tokenize_rows (pandas/parser.c:11308)
File "pandas/parser.pyx", line 2014, in pandas.parser.raise_parser_error (pandas/parser.c:26862)
TypeError: raise: exception class must be a subclass of BaseException
我尝试了一些不同的侵蚀类型,但仍然相同......任何想法?
答案 0 :(得分:0)
退房:
https://github.com/pandas-dev/pandas/issues/6035
并尝试将分隔符转换为字符串?
class CassandraJournal(implicit val system: ActorSystem) {
def engageStreaming = {
val readJournal = PersistenceQuery(system).readJournalFor[CassandraReadJournal](CassandraReadJournal.Identifier)
implicit val mat = ActorMaterializer()
readJournal.eventsByTag("account", Offset.noOffset)
.runForeach { event => println(event) }
}
}