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

Python vivopump.write_csv_fp函数代码示例

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

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



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

示例1: test_write_csv_fp

 def test_write_csv_fp(self):
     data = read_csv("data/buildings.txt", delimiter='\t')
     fp = open('data/buildings_out.txt', 'w')
     write_csv_fp(fp, data, delimiter='\t')
     fp.close()
     data2 = read_csv("data/buildings.txt", delimiter='\t')
     self.assertTrue(data == data2)
开发者ID:KevinHanson,项目名称:vivo-pump,代码行数:7,代码来源:test_vivopump.py


示例2: read_csv_fp

"""
    null_value_filter.py -- Replace "NULL" with empty string
"""

__author__ = "Michael Conlon"
__copyright__ = "Copyright 2015 (c), Michael Conlon"
__license__ = "New BSD License"
__version__ = "0.01"

from vivopump import read_csv_fp, write_csv_fp
import shelve
import sys

data_in = read_csv_fp(sys.stdin)
data_out = {}
null_count = 0
for row, data in data_in.items():
    new_data =dict(data)
    for name, val in new_data.items():
        if val == "NULL":
            new_data[name] = ""
            null_count += 1
    data_out[row] = new_data
print >>sys.stderr, "NULL values replaced", null_count
write_csv_fp(sys.stdout, data_out)





开发者ID:KevinHanson,项目名称:vivo-pump,代码行数:25,代码来源:null_value_filter.py


示例3: get_author_affiliation

    data_out['affiliation'] = get_author_affiliation(row_data['affiliation'])

    try:
        if len(vivo_journals.get(row_data['issn'])) > 0:
            issn_uri = vivo_journals.get(row_data['issn'])
        else:
            utils.print_err("\nISSN not found: {}\n".format(row_data['issn']))
            issn_uri = ''
    except TypeError:
        continue

    # try:
    #     issn_uri = vivo_journals.get(row_data['issn'])
    # except KeyError:
    #     utils.print_err("\nISSN not found: {}\n".format(row_data['issn']))
    #     issn_uri = ''

    utils.print_err("data_out is: \n{}".format(data_out))

    data_in[row_index]['author'] = data_out['author']
    data_in[row_index]['affiliation'] = data_out['affiliation']
    data_in[row_index]['journal'] = issn_uri
    data_in[row_index].pop('issn')

for line in disamb_dict:
    disamb_file.write(line)

disamb_file.close()

write_csv_fp(sys.stdout, data_in)
开发者ID:ctsit,项目名称:vivo-pump,代码行数:30,代码来源:pub_author_match_filter.py


示例4: len

        pubs_missing_doi_dict[row]= data
        continue

    data_out[row] = data

    # name is not vivo.  These are the ones to add
    if data['doi'] not in vivo_pubs:
        data_out[row]['uri'] = ''
    else:
        data_out[row]['uri'] = vivo_pubs[data['doi']]

    try:
        if len(vivo_journals.get(data['issn'])) > 0:
            issn_uri = vivo_journals.get(data['issn'])
        else:
            utils.print_err("\nISSN not found: {}\n".format(data['issn']))
            issn_uri = ''
    except TypeError:
        continue

    data_out[row]['journal'] = issn_uri
    data_out[row].pop('issn')




write_csv_fp(pubs_missing_doi_file,pubs_missing_doi_dict)

utils.print_err('{} rows in the output'.format(len(data_out)))
write_csv_fp(sys.stdout, data_out)
开发者ID:ctsit,项目名称:vivo-pump,代码行数:30,代码来源:pub_match_filter.py


示例5: bib2csv

def bib2csv(bib_data):
    """
    Given bib_data as created by bibtexparser, return a csv object as modeled by vivotools
    :param bib_data:
    :return: csv_data
    """
    csv_data = {}
    row = 0
    col_names = set(y for x in bib_data.entries for y in x.keys())
    for x in bib_data.entries:
        row += 1
        csv_data[row] = {}
        for col_name in col_names:
            v = x.get(col_name, "")
            v = v.replace("\n", " ")
            v = v.replace("\r", " ")
            v = v.replace("\t", " ")
            csv_data[row][col_name] = v
    return csv_data


bib_str = ""
for line in sys.stdin:
    bib_str += line

bib_data = loads(bib_str)
print >>sys.stderr, "Entries", len(bib_data.entries)
csv_data = bib2csv(bib_data)
print >>sys.stderr, "Rows", len(csv_data)
write_csv_fp(sys.stdout, csv_data)
开发者ID:KevinHanson,项目名称:vivo-pump,代码行数:30,代码来源:bib2csv_filter.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python viz.add函数代码示例发布时间:2022-05-26
下一篇:
Python utils.create_vertex函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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