本文整理汇总了Python中pybabe.Babe类的典型用法代码示例。如果您正苦于以下问题:Python Babe类的具体用法?Python Babe怎么用?Python Babe使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Babe类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_partition
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')
开发者ID:IsCoolEntertainment,项目名称:PyBabe,代码行数:7,代码来源:test_partition.py
示例2: test_http
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')
开发者ID:IsCoolEntertainment,项目名称:PyBabe,代码行数:7,代码来源:test_http.py
示例3: test_user_agent
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)
开发者ID:IsCoolEntertainment,项目名称:PyBabe,代码行数:7,代码来源:test_user_agent.py
示例4: test_join_none
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)
开发者ID:IsCoolEntertainment,项目名称:PyBabe,代码行数:7,代码来源:test_join.py
示例5: test_twitter
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')
开发者ID:nizox,项目名称:PyBabe,代码行数:7,代码来源:tests.py
示例6: test_replace
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)
开发者ID:nizox,项目名称:PyBabe,代码行数:7,代码来源:tests.py
示例7: test_html
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>
""")
开发者ID:IsCoolEntertainment,项目名称:PyBabe,代码行数:7,代码来源:test_html.py
示例8: test_bulk
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)
开发者ID:IsCoolEntertainment,项目名称:PyBabe,代码行数:7,代码来源:test_transform.py
示例9: test_multi2
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)
开发者ID:fdouetteau,项目名称:PyBabe,代码行数:7,代码来源:test_base.py
示例10: test_zip
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)
开发者ID:nizox,项目名称:PyBabe,代码行数:8,代码来源:tests.py
示例11: test_load
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()
开发者ID:nizox,项目名称:PyBabe,代码行数:8,代码来源:tests.py
示例12: test_buzzdata
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')
开发者ID:nizox,项目名称:PyBabe,代码行数:8,代码来源:tests.py
示例13: test_insert
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)
开发者ID:fdouetteau,项目名称:PyBabe,代码行数:8,代码来源:test_transform.py
示例14: test_sort
def test_sort(self):
babe = Babe()
s = '\n'.join(['k,v'] + [ '%u,%u' % (i,-i) for i in xrange(0,10001)])
a = babe.pull(string=s, name='test', format='csv')
a = a.typedetect()
a = a.sort(field='v')
a = a.head(n=1)
self.assertEquals(a.to_string(), 'k,v\n10000,-10000\n')
开发者ID:fdouetteau,项目名称:PyBabe,代码行数:8,代码来源:test_sort.py
示例15: test_sort
def test_sort(self):
babe = Babe()
s = "\n".join(["k,v"] + ["%u,%u" % (i, -i) for i in xrange(0, 10001)])
a = babe.pull(string=s, name="test", format="csv")
a = a.typedetect()
a = a.sort(field="v")
a = a.head(n=1)
self.assertEquals(a.to_string(), "k,v\n10000,-10000\n")
开发者ID:IsCoolEntertainment,项目名称:PyBabe,代码行数:8,代码来源:test_sort.py
示例16: test_tuple
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)
开发者ID:fdouetteau,项目名称:PyBabe,代码行数:8,代码来源:test_transform.py
示例17: test_ftp
def test_ftp(self):
babe = Babe()
a = babe.pull(filename='tests/test.csv', name='Test')
a.push(filename='test.csv', protocol='ftp', user=self.user, password=self.password, host='localhost', port=self.port, protocol_early_check= False)
b = babe.pull(filename='test.csv', name='Test', protocol='ftp', user=self.user, password=self.password, host='localhost', port=self.port)
buf = StringIO()
b.push(stream=buf, format='csv')
self.assertEquals(buf.getvalue(), test_csv_content)
开发者ID:nizox,项目名称:PyBabe,代码行数:8,代码来源:tests.py
示例18: test_load_partition
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"])
开发者ID:IsCoolEntertainment,项目名称:PyBabe,代码行数:8,代码来源:test_kontagent.py
示例19: test_s3
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")
开发者ID:IsCoolEntertainment,项目名称:PyBabe,代码行数:9,代码来源:test_google_storage.py
示例20: test_parse
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)
开发者ID:IsCoolEntertainment,项目名称:PyBabe,代码行数:9,代码来源:test_transform.py
注:本文中的pybabe.Babe类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论