本文整理汇总了Python中pybabe.Babe.push方法的典型用法代码示例。如果您正苦于以下问题:Python Babe.push方法的具体用法?Python Babe.push怎么用?Python Babe.push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybabe.Babe
的用法示例。
在下文中一共展示了Babe.push方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_multi2
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import push [as 别名]
def test_multi2(self):
a = Babe()
a = a.pull(stream=StringIO(self.s), format='csv').pull(string=self.s, format='csv')
a = a.merge_substreams()
buf = StringIO()
a.push(stream=buf, format='csv')
self.assertEquals(buf.getvalue(), self.s2)
示例2: test_gz
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import push [as 别名]
def test_gz(self):
a = Babe().pull(stream=StringIO(self.s), format='csv', name='Test')
a.push(filename='test.csv.gz')
b = Babe().pull(filename='test.csv.gz')
buf = StringIO()
b.push(stream=buf, format='csv')
self.assertEquals(buf.getvalue(), self.s)
示例3: test_partition
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import push [as 别名]
def test_partition(self):
a = Babe().pull(string=self.s, format="csv")
a = a.partition(field="date")
d = {}
a.push(stream_dict=d, format="csv")
self.assertEquals(d["2012-04-04"].getvalue(), "date,name,value\n2012-04-04,John,1\n2012-04-04,Luke,2\n")
self.assertEquals(d["2012-04-05"].getvalue(), "date,name,value\n2012-04-05,John,1\n")
示例4: test_bulk
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import push [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"])
buf = StringIO()
a.push(stream=buf, format="csv")
self.assertEquals(buf.getvalue(), self.s2)
示例5: test_twitter
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import push [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()
buf = StringIO()
a.push(stream=buf, format='csv')
示例6: test_replace
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import push [as 别名]
def test_replace(self):
a = Babe().pull(filename='tests/test.csv', name='Test').typedetect()
a = a.mapTo(lambda row : [row.foo+1, row.bar*2], fields=['a','b'])
buf = StringIO()
a.push(stream=buf, format='csv')
s = """a,b\n2,4\n4,8\n"""
self.assertEquals(buf.getvalue(), s)
示例7: test_s3
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import push [as 别名]
def test_s3(self):
s = "a,b\n1,a\n3,b\n"
filename = 'tests/test_bq.csv'
a = Babe().pull(string=s,
format='csv',
name='Test')
a.push(filename=filename,
format='csv',
delimiter='\t',
quotechar='|',
encoding='utf8',
bucket='bertrandtest',
protocol='gs')
b = Babe()
b.push_bigquery(filename=filename,
bucket='bertrandtest',
project_id='bigquery-testing-1098',
dataset_id='ladata',
table_name='tests',
schema=[
{
"name": "entier",
"type": "INTEGER",
"mode": "REQUIRED"
},
{
"name": "string",
"type": "STRING",
"mode": "REQUIRED"
}
])
示例8: test_zip
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import push [as 别名]
def test_zip(self):
babe = Babe()
a = babe.pull(stream=StringIO(self.s), format="csv")
a.push(filename='tests/test.zip')
b = Babe().pull(filename='tests/test.zip')
buf = StringIO()
b.push(stream=buf)
self.assertEquals(buf.getvalue(), self.s)
示例9: test_load
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import push [as 别名]
def test_load(self):
start_time = '2012-04-23 11:00'
end_time = '2012-04-23 12:00'
a = Babe().pull_kontagent(start_time, end_time, sample_mode=True)
buf = StringIO()
a = a.head(n=10)
a.push(stream=buf, format='csv')
print buf.getvalue()
示例10: test_vectorwise
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import push [as 别名]
def test_vectorwise(self):
a = Babe().pull(stream=StringIO(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')
buf = StringIO()
b.push(stream=buf, format='csv', delimiter=',')
self.assertEquals(buf.getvalue(), self.s)
示例11: test_buzzdata
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import push [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)
buf = StringIO()
a.push(stream=buf, format='csv')
示例12: test_pushpull
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import push [as 别名]
def test_pushpull(self):
a = Babe().pull(stream=StringIO(self.s2), format='csv', primary_key='rown')
a = a.typedetect()
a.push_mongo(db='pybabe_test',collection='test_pushpull', drop_collection=True)
b = Babe().pull_mongo(db="pybabe_test", fields=['rown', 'f', 's'], collection='test_pushpull')
buf = StringIO()
b.push(stream=buf, format='csv')
self.assertEquals(buf.getvalue(), self.s2)
示例13: test_load_partition
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import push [as 别名]
def test_load_partition(self):
start_time = "2012-04-23 11:00"
end_time = "2012-04-23 12:00"
a = Babe().pull_kontagent(start_time, end_time, sample_mode=True)
a = a.head(n=10)
d = {}
a.push(stream_dict=d, format="csv")
self.assertEquals(list(d.keys()), ["2012-04-23_11"])
示例14: test_s3_glob2
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import push [as 别名]
def test_s3_glob2(self):
s = "a,b\n1,2\n3,4\n"
buf1 = StringIO(s)
a = Babe().pull(stream=buf1, format='csv', name='Test')
a.push(filename='foofoobar/test_glob_4.csv', bucket='florian-test', protocol="s3")
b = Babe().pull(filename='foofoobar/test_glob_?.csv', name='Test', bucket='florian-test', protocol="s3")
buf = StringIO()
b.push(stream=buf, format='csv')
self.assertEquals(buf.getvalue(), s)
示例15: test_s3
# 需要导入模块: from pybabe import Babe [as 别名]
# 或者: from pybabe.Babe import push [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='test_gs.csv',
bucket='bertrandtest',
delimiter="\t",
protocol="gs")