当前位置: 首页>>代码示例>>Python>>正文


Python vivopump.write_csv_fp函数代码示例

本文整理汇总了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;未经允许,请勿转载。