I just want to read a CSV file from a Github repo with PyGithub.
from github import Github
g = Github(token)
repo = g.get_repo("user/example")
contents = repo.get_contents("h.csv")
with open(contents, "r") as f1:
last_line = f1.readlines()[-1]
last_id_csv = last_line.split(",")[0]
But I don't know how to manage ContentFile() type to have the CSV file.
CSV file content is something like:
id,number,text
1,1234,blabla
2,2345,blabla
3,4534,blabla
4,3423,blabla
Thanks for your help.
from github import Github g = Github(token) repo = g.get_repo("user/example") contents = repo.get_contents("h.csv") inputFile = contents.decoded_content.decode('utf-8') tocsv = csv.reader(inputFile, delimiter=',') for row in tocsv: print(row)