dril.py 文件源码

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

项目:AestheticDril 作者: rhodochrosiite 项目源码 文件源码
def _build_file(self):
        self.total_rows = 0 

        #Get recent tweets from dril and add to new file
        for status in tweepy.Cursor(api.user_timeline, 'dril', since_id=self.since).items():
            self.total_rows += self._process_status(status)

        #Put content of old file in new file
        #This is kind of messy uhhh
        try:
            #Open things for reading and writing
            readFile = open('data/dril.csv', 'rt', encoding='utf-8')
            writeFile = open('data/new.csv', 'at', encoding='utf-8')

            read = reader(readFile)
            write = writer(writeFile, delimiter=',', quoting=QUOTE_NONNUMERIC) #Uhhhhmmmmmhmh mmmm

            for row in read:
                write.writerow([int(row[0]), row[1]])
                self.total_rows += 1
        except IOError:
            print('Failed to open file (1) [okay if this is the first time running]')

        #Rename the new file to be the old file
        os.rename('data/new.csv', 'data/dril.csv')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号