xlstools.py 文件源码

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

项目:finance_news_analysis 作者: pskun 项目源码 文件源码
def read_csv(filename, skip_lines=0):
    csvfile = file(filename, 'rb')
    reader = csv.reader(csvfile)
    data = np.empty(0, dtype=object)
    last_count = np.NAN
    for line in reader:
        if skip_lines > 0:
            skip_lines = skip_lines - 1
            continue
        if data.size > 0:
            if len(line) != last_count:
                raise Exception('unequal columes found')
            data = np.c_[data, line]
            last_count = len(line)
        else:
            data = np.array(line, dtype=object)
            data = data.reshape(len(data), 1)
            last_count = len(line)
    csvfile.close()
    return data.T
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号