Forums

Home Directory doesn't apply.

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

In the code that you've posted, you've specifically asked for the file to be created in /home/psp219/YahooFinanceOptionCrawler/, so it should be created there. If it isn't then there's something else wrong like you're not running the code that you posted (maybe you're looking at and editing the wrong file or you haven't reloaded your webapp or something like that)

I don't think I'm running the wrong file. This is the code I tried yesterday from the bash from the dashboard

Do I need to reload the web app anytime I make a change?

Yes, you do. If you're editing code using our in-browser editor, then you should have a "Reload" icon near the top right.

[edit] can't tell left from right...