Currently, I've got a program that scrapes some HTML/Web page and writes some results to a CSV file. No matter how I manually specify the home directory, the CSV file is always written to /home/psp219/ rather than /home/psp219/projectname. Ive tried using os.dirpath and hard coding the names in and still getting nothing.
def create_csv(call_list, file_name):
csvfile = open("/home/psp219/YahooFinanceOptionCrawler/" + file_name,'wb')
csvwriter = csv.writer(csvfile, delimiter = ',')
csvwriter.writerow(['Underlying Ticker', 'Strike Price', 'Ask', 'Bid'])
for option in call_list:
csvwriter.writerow([option['contractSymbol'], option['strike']['fmt'], option['ask']['fmt'], option['bid']['fmt']])
csvfile.close()
The file is always created in /home/psp219 whereas I want it to be created in /home/psp219/projectname