python - Grab file from Desktop in Django Shell -
i have app named cars inside django project has utils.py file contains various utility methods used application. 1 of them (grab_new_models) used process csv file that's picked via periodic tasks fetches file remote location. method passed csv file method looks like
def grab_new_models(csv_file):
right i'm trying update code new functionality , having issues testing locally. using django shell, can't figure out how pass file method test it. have copy of csv file on desktop. how call method django shell , pass local csv file?
so on django shell, python shell imports. can import util , call function. below provide simple example, reads simple file desktop , prints it:
method:
def grab_new_models(csv_file): open(csv_file) f1: = f1.read() print(a)
execution:
grab_new_models(r'c:\users\l3\desktop\learn_note.txt')
Comments
Post a Comment