__init__.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:girder_worker 作者: girder 项目源码 文件源码
def csv_to_rows(input):
    reader = get_csv_reader(input)
    rows = [d for d in reader]
    fields = reader.fieldnames

    output = {'fields': fields, 'rows': rows}

    # Attempt numeric conversion
    for row in output['rows']:
        for col in row:
            try:
                row[col] = int(row[col])
            except Exception:
                try:
                    orig = row[col]
                    row[col] = float(row[col])

                    # Disallow NaN, Inf, -Inf since this does not
                    # pass through JSON converters cleanly
                    if math.isnan(row[col]) or math.isinf(row[col]):
                        row[col] = orig
                except Exception:
                    pass

    return output
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号