DataGatherer.py 文件源码

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

项目:pubchem-ranker 作者: jacobwindsor 项目源码 文件源码
def harvest(self, limit=None, offset=None):
        """

        Harvest the data from the file
        :param offset: Integer offset for the row - starts from 0
        :param limit: Interger limit of the rows to iterate over - starts from 0
        :return: list of tuples containing CAS number and IUPAC name
        """
        response = []
        for i, row in enumerate(list(self.reader)[offset:]):
            if limit:
                if i == limit:
                    break

            cas = row[0].split(' ', 1)[0]
            cut_start_iupac = str(row[0].split('(', 1)[1])
            iupac = cut_start_iupac.rsplit(')', 1)[0]

            response.append({
                "CAS": cas,
                "IUPAC": iupac
            })

        return response
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号