You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Spyder_python/service/CsvService.py

22 lines
1023 B

7 months ago
from service.IFileService import IFileService
8 months ago
from entity.BilibiliVideo import BilibiliVideo
7 months ago
from controller.SpyderController import SpyderController
import csv
8 months ago
class CsvService(IFileService):
def save(self, filePath, videoList: list[BilibiliVideo]):
7 months ago
f = open(filePath+".csv", "w", encoding="UTF-8", newline="")
7 months ago
csv_writer = csv.writer(f)
csv_writer.writerow(
["topNo", "bvId", "title", "url", "uploadTime", "viewCount", "likeCount", "coinCount", "favoriteCount",
"bulletCount", "commentCount",
"creatorId", "creatorName", "creatorFanCount"])
for video in videoList:
csv_writer.writerow(
[video.topNo, video.bvId, video.title, video.url, video.uploadTimeText, video.viewCount, video.likeCount,
video.coinCount, video.favoriteCount, video.bulletCount, video.commentCount,
video.creatorId, video.creatorName, video.creatorFanCount])
f.close()
# raise NotImplementedError
7 months ago