import_data.py 文件源码

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

项目:find-that-charity 作者: TechforgoodCAST 项目源码 文件源码
def import_extract_main(chars={}, datafile=os.path.join("data", "ccew", "extract_main_charity.csv")):

    with open(datafile, encoding="latin1") as a:
        csvreader = csv.reader(a, doublequote=False, escapechar='\\')
        ccount = 0
        for row in csvreader:
            if len(row) > 1:
                row = clean_row(row)
                if row[1]:
                    chars[row[0]]["company_number"].append({
                        "number": parse_company_number(row[1]),
                        "url": "http://beta.companieshouse.gov.uk/company/" + parse_company_number(row[1]),
                        "source": "ccew"
                    })
                if row[9]:
                    chars[row[0]]["url"] = row[9]
                if row[6]:
                    chars[row[0]]["latest_income"] = int(row[6])
                ccount += 1
                if ccount % 10000 == 0:
                    print('\r', "[CCEW] %s charities read from extract_main_charity.csv" % ccount, end='')
        print('\r', "[CCEW] %s charities read from extract_main_charity.csv" % ccount)

    return chars
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号