本文整理汇总了Python中pybabe.Babe.to_string方法的典型用法代码示例。如果您正苦于以下问题:Python Babe.to_string方法的具体用法?Python Babe.to_string怎么用?Python Babe.to_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybabe.Babe
的用法示例。
在下文中一共展示了Babe.to_string方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_buzzdata
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import to_string [as 别名]
def test_buzzdata(self):
a = Babe().pull(
protocol="buzzdata",
dataroom="best-city-contest-worldwide-cost-of-living-index",
uuid="aINAPyLGur4y37yAyCM7w3",
username="eiu",
format="xls",
)
a = a.head(2)
a.to_string()
示例2: test_twitter
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import to_string [as 别名]
def test_twitter(self):
a = Babe().pull_twitter()
a = a.filterColumns(keep_fields=["author_name",
"author_id",
"author_screen_name",
"created_at",
"hashtags",
"text",
"in_reply_to_status_id_str"])
a = a.typedetect()
a.to_string()
示例3: test_bulk
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import to_string [as 别名]
def test_bulk(self):
a = Babe().pull(stream=StringIO(self.s), format="csv")
a = a.typedetect()
a = a.bulkMapTo(lambda list: [[sum([r.a for r in list])]] * len(list),
bulk_size=2,
insert_fields=["b"])
self.assertEquals(a.to_string(), self.s2)
示例4: test_user_agent
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import to_string [as 别名]
def test_user_agent(self):
a = Babe().pull(string=self.s, format="csv")
a = a.user_agent(field="useragent",
output_os="os",
output_browser="browser",
output_browser_version="browser_version")
self.assertEquals(a.to_string(), self.s2)
示例5: test_join_none
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import to_string [as 别名]
def test_join_none(self):
a = Babe().pull(string=self.s1, format='csv')
a = a.join(join_stream=Babe().pull(string=self.s2_bis, format='csv'),
key='country',
join_key='country_code',
on_error=Babe.ON_ERROR_NONE)
self.assertEquals(a.to_string(), self.sjoined_bis)
示例6: test_http
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import to_string [as 别名]
def test_http(self):
a = Babe().pull(protocol='http',
host='localhost',
name='Test',
filename='remote/files/test.csv',
port=self.port)
self.assertEquals(a.to_string(), 'foo,bar,f,d\n1,2,3.2,2010/10/02\n3,4,1.2,2011/02/02\n')
示例7: test_html
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import to_string [as 别名]
def test_html(self):
a = Babe().pull(string=self.s, format="csv")
self.assertEqual(a.to_string(format="html"), """<h2></h2><table>
<tr><th>a</th><th>b</th></tr>
<tr><td>1</td><td>2</td></tr>
</table>
""")
示例8: test_insert
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import to_string [as 别名]
def test_insert(self):
a = Babe().pull(filename='tests/test.csv', name='Test').typedetect()
a = a.mapTo(lambda row : row.foo+1, insert_fields=['fooplus'])
s = """foo,bar,f,d,fooplus
1,2,3.2,2010/10/02,2
3,4,1.2,2011/02/02,4
"""
self.assertEquals(a.to_string(), s)
示例9: test_tuple
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import to_string [as 别名]
def test_tuple(self):
a = Babe().pull(filename='tests/test.csv', name='Test').typedetect()
a = a.mapTo(lambda obj: obj._replace(foo=obj.foo + 1))
s = """foo,bar,f,d
2,2,3.2,2010/10/02
4,4,1.2,2011/02/02
"""
self.assertEquals(a.to_string(), s)
示例10: test_parse
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import to_string [as 别名]
def test_parse(self):
a = Babe().pull(stream=StringIO(self.s), format='csv')
a = a.parse_time(field="time",
output_time="time",
output_date="date",
output_hour="hour",
input_timezone="CET",
output_timezone="GMT")
self.assertEquals(a.to_string(), self.s2)
示例11: test_pushsqlite
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import to_string [as 别名]
def test_pushsqlite(self):
a = Babe().pull(string=self.s, format='csv')
a = a.typedetect()
a.push_sql(table='test_table',
database_kind='sqlite',
database='tests/files/test.sqlite',
drop_table=True,
create_table=True)
b = Babe().pull_sql(database_kind='sqlite',
database='tests/files/test.sqlite',
table='test_table')
self.assertEquals(b.to_string(), self.s)
示例12: test_pull_bigquery
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import to_string [as 别名]
def test_pull_bigquery(self):
dataset_id = 'ladata'
day = '20151010'
table_name = 'crazy_{}'.format(day)
query = """
SELECT
uid,
count(1)
FROM
[{}.{}]
WHERE
name='pgr'
GROUP BY 1
ORDER BY 2 DESC;""".format(dataset_id, table_name)
a = Babe().pull_bigquery(project_id='bigquery-testing-1098',
query=query,
timeout=1000,
num_retries=2)
print a.to_string()
示例13: test_pushsqlite_partition
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import to_string [as 别名]
def test_pushsqlite_partition(self):
a = Babe().pull(string=self.s, format='csv')
a = a.typedetect()
a.push_sql(table='test_table', database_kind='sqlite', database='test.sqlite', drop_table = True, create_table=True)
a = Babe().pull(string=self.s2, format='csv')
a = a.typedetect()
a = a.partition(field='id')
a.push_sql(table='test_table', database_kind='sqlite', database='test.sqlite', delete_partition=True)
b = Babe().pull_sql(database_kind='sqlite', database='test.sqlite', table='test_table')
b = b.sort(field="id")
self.assertEquals(b.to_string(), self.sr)
示例14: test_vectorwise
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import to_string [as 别名]
def test_vectorwise(self):
a = Babe().pull(string=self.s,
format='csv')
a = a.typedetect()
a.push_sql(table='test_table',
database_kind='vectorwise',
database='pybabe_test',
drop_table=True,
create_table=True)
b = Babe().pull_sql(database_kind='vectorwise',
database='pybabe_test',
table='test_table')
self.assertEquals(b.to_string(), self.s)
示例15: test_s3
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import to_string [as 别名]
def test_s3(self):
s = "a,b\n1,2\n3,4\n"
a = Babe().pull(string=s,
format='csv',
name='Test')
a.push(filename='test3.csv',
bucket='florian-test',
protocol="s3")
b = Babe().pull(filename='test3.csv',
name='Test',
bucket='florian-test',
protocol="s3")
self.assertEquals(b.to_string(), s)