• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python table_fu.TableFu类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中table_fu.TableFu的典型用法代码示例。如果您正苦于以下问题:Python TableFu类的具体用法?Python TableFu怎么用?Python TableFu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TableFu类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_map_values

 def test_map_values(self):
     """
     Test mapping a function to specific column values
     """
     t = TableFu(self.table)
     result = [s.lower() for s in t.values('Style')]
     self.assertEqual(result, t.map(str.lower, 'Style'))
开发者ID:JNRowe-retired,项目名称:python-tablefu,代码行数:7,代码来源:test.py


示例2: test_sort_option_int

 def test_sort_option_int(self):
     "Sorting the table by an int field, Number of Pages"
     t = TableFu(self.csv_file)
     pages = t.values('Number of Pages')
     pages = sorted(pages, reverse=True)
     t.sort('Number of Pages', reverse=True)
     self.assertEqual(t.values('Number of Pages'), pages)
开发者ID:JNRowe-retired,项目名称:python-tablefu,代码行数:7,代码来源:test.py


示例3: test_row_map

 def test_row_map(self):
     """
     Test map a function to rows, or a subset of fields
     """
     t = TableFu(self.table)
     result = [s.lower() for s in t.values('Style')]
     self.assertEqual(result, t.map(lambda row: row['Style'].value.lower()))
开发者ID:JNRowe-retired,项目名称:python-tablefu,代码行数:7,代码来源:test.py


示例4: test_limit_columns

 def test_limit_columns(self):
     "Column definitions are passed to rows"
     t = TableFu(self.csv_file)
     t.columns = ['Author', 'Style']
     self.assertEqual(
         str(t[0]),
         'Samuel Beckett, Modernism'
         )
开发者ID:gijs,项目名称:python-tablefu,代码行数:8,代码来源:test.py


示例5: test_facet

 def test_facet(self):
     "Facet tables based on shared column values"
     t = TableFu(self.csv_file)
     tables = t.facet_by('Style')
     style_row = self.table[4]
     self.assertEqual(
         style_row,
         tables[2][0].cells
     )
开发者ID:gijs,项目名称:python-tablefu,代码行数:9,代码来源:test.py


示例6: test_cell_format

    def test_cell_format(self):
        "Format a cell"
        t = TableFu(self.csv_file)
        t.formatting = {'Name': {'filter': 'link', 'args': ['URL']}}

        self.assertEqual(
            str(t[0]['Name']),
            '<a href="http://www.chrisamico.com" title="ChrisAmico.com">ChrisAmico.com</a>'
        )
开发者ID:JNRowe-retired,项目名称:python-tablefu,代码行数:9,代码来源:test.py


示例7: testFacets

 def testFacets(self):
     table = Table(self.yml)
     options = self.parsed['table']['column_options']
     url = "http://spreadsheets.google.com/pub?key=tcSL0eqrj3yb5d6ljak4Dcw&output=csv"
     response = urllib2.urlopen(url)
     tf = TableFu(response, **options)
     tables = tf.facet_by('State')
     for i, t in enumerate(tables):
         self.assertEqual(t.table, table.data[i].table)
开发者ID:JoeGermuska,项目名称:flask-tablesetter,代码行数:9,代码来源:test.py


示例8: test_transform_to_int

 def test_transform_to_int(self):
     """
     Convert the Number of Pages field to integers
     """
     t = TableFu(self.csv_file)
     pages = t.values('Number of Pages')
     t.transform('Number of Pages', int)
     for s, i in zip(pages, t.values('Number of Pages')):
         self.assertEqual(int(s), i)
开发者ID:JNRowe-retired,项目名称:python-tablefu,代码行数:9,代码来源:test.py


示例9: test_map_many_values

 def test_map_many_values(self):
     """
     Test mapping a function to multiple columns
     """
     t = TableFu(self.table)
     result = [
         [s.lower() for s in t.values(value)]
         for value in ['Best Book', 'Style']
     ]
     self.assertEqual(result, t.map(str.lower, 'Best Book', 'Style'))
开发者ID:JNRowe-retired,项目名称:python-tablefu,代码行数:10,代码来源:test.py


示例10: test_sort

 def test_sort(self):
     "Sort a table in place"
     t = TableFu(self.csv_file)
     self.table.pop(0)
     self.table.sort(key=lambda row: row[0])
     t.sort('Author')
     self.assertEqual(
         t[0].cells,
         self.table[0]
     )
开发者ID:gijs,项目名称:python-tablefu,代码行数:10,代码来源:test.py


示例11: _open

 def _open(self):
     if self.url:
         f = urllib2.urlopen(self.url)
     elif self.filename:
         f = open(self.filename, 'rb')
     else: # there's neither a url nor a file
         raise TableError("You must specify a google_key, URL or local file containing CSV data")
     
     t = TableFu(f, **self.options.get('column_options', {}))
     if self.options.get('faceting', False):
         return t.facet_by(self.options['faceting']['facet_by'])
     return t
开发者ID:JoeGermuska,项目名称:flask-tablesetter,代码行数:12,代码来源:table.py


示例12: test_json

    def test_json(self):
        try:
            import json
        except ImportError:
            try:
                import simplejson as json
            except ImportError:
                return

        t = TableFu(self.csv_file)
        self.csv_file.seek(0)
        reader = csv.DictReader(self.csv_file)
        jsoned = json.dumps([row for row in reader])
        self.assertEqual(t.json(), jsoned)
开发者ID:JNRowe-retired,项目名称:python-tablefu,代码行数:14,代码来源:test.py


示例13: test_from_url

 def test_from_url(self):
     if not os.getenv('TEST_REMOTE'):
         return True
     url = "http://spreadsheets.google.com/pub?key=thJa_BvqQuNdaFfFJMMII0Q&output=csv"
     t1 = TableFu.from_url(url)
     t2 = TableFu(urllib2.urlopen(url))
     self.assertEqual(t1.table, t2.table)
开发者ID:JNRowe-retired,项目名称:python-tablefu,代码行数:7,代码来源:test.py


示例14: csvviresult

def csvviresult():
    global table
    # data = request.form['text']
    # table = TableFu.from_file('app/vi-csv.csv')
    table = TableFu.from_file('app/vi-csv.csv')
    # return render_template('vi-template.html', table=table)
    return render_template('vi-template.html', table=table)
开发者ID:cornelius-k,项目名称:localflaskhighlights,代码行数:7,代码来源:views.py


示例15: test_transpose

 def test_transpose(self):
     t = TableFu(self.table)
     result = [
         ['Author', 'Samuel Beckett', 'James Joyce', 'Nicholson Baker', 'Vladimir Sorokin'],
         ['Best Book', 'Malone Muert', 'Ulysses', 'Mezannine', 'The Queue'],
         ['Number of Pages', '120', '644', '150', '263'],
         ['Style', 'Modernism', 'Modernism', 'Minimalism', 'Satire']
     ]
     
     transposed = t.transpose()
     self.assertEqual(transposed.table, result[1:])
     self.assertEqual(transposed.columns, [
         'Author',
         'Samuel Beckett',
         'James Joyce',
         'Nicholson Baker',
         'Vladimir Sorokin'
     ])
开发者ID:goldenboy,项目名称:python-tablefu,代码行数:18,代码来源:test.py


示例16: test_set_columns

    def test_set_columns(self):
        arra = TableFu.from_file(self.filename)
        arra.columns = ["State", "County", "Urban Area"]

        tabled = Table(
            title="That Stimulus", added_by=self.user, file=File(self.file), columns=["State", "County", "Urban Area"]
        )
        tabled.save()

        self.assertEqual(arra.columns, tabled.data.columns)
开发者ID:homicidewatch,项目名称:table-masher,代码行数:10,代码来源:models.py


示例17: data

 def data(self):
     """Return a TableFu instance with data for this model"""
     if hasattr(self, '_data') and self._data is not None:
         return self._data
     
     if self.file:
         # this gets wrapped in a with block for cleanliness
         d = TableFu.from_file(self.file.path)
     
     elif self.url:
         d = TableFu.from_url(self.url)
     
     else:
         return None
             
     if self.columns:
         d.columns = self.columns
     
     self._data = d
     return self._data
开发者ID:homicidewatch,项目名称:table-masher,代码行数:20,代码来源:models.py


示例18: virtualissueautomate

def virtualissueautomate():
    
    myDOIs = str(request.form["text"]).split('\r\n')
    
 
     # run python process
    createVI(myDOIs)

    global table
    # data = request.form['text']
    table = TableFu.from_file('vi-csv.csv')
    return render_template('vi-template.html', table=table, results=results)
开发者ID:cornelius-k,项目名称:localflaskhighlights,代码行数:12,代码来源:views.py


示例19: podcastupload

def podcastupload():
    if request.method == 'POST':
    # Get the name of uploaded file
        file = request.files['file']
        # Check if the file is an allowed extension
        if file and allowed_file(file.filename):
            # Make the filename safe - remove unsupported characters
            filename = secure_filename(file.filename)
            # # Move the file from the temp folder to the upload folder
            file.save(os.path.join(app.config["UPLOAD_FOLDER"], filename))
            # Use tablefu to template out the uploaded CSV file
            global table
            table = TableFu.from_file('app/static/uploads/' + filename)
            return render_template('podcastresults.html', table=table)
开发者ID:tsboom,项目名称:localflaskhighlights,代码行数:14,代码来源:views.py


示例20: facet

def facet(starter, *facets):
    table = TableFu.from_file(starter)
    out_dir = os.path.dirname(starter)
    files = []
    for f in facets:
        try:
            tables = table.facet_by(f)
        except KeyError:
            sys.stderr.write('Bad column name: %s\n' % f)
            sys.stderr.write('Available columns: %s\n\n' % ', '.join(table.columns))
            continue

        for t in tables:
            out = open(os.path.join(out_dir, '%s.csv' % t.faceted_on), 'wb')
            out.write(t.csv().getvalue())
            out.close()
            files.append(out.name)
    
    return files
开发者ID:homicidewatch,项目名称:table-masher,代码行数:19,代码来源:facet.py



注:本文中的table_fu.TableFu类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tableau.Tableau类代码示例发布时间:2022-05-27
下一篇:
Python table.Table类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap