Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all,
Vanilla are planning an update to the site on April 24th (next Wednesday). It is a major PHP8 update which is expected to boost performance across the site. The site will be down from 7pm and it is expected to take about an hour to complete. We appreciate your patience during the update.
Thanks all.

Python import problem

Options
  • 28-12-2014 8:47pm
    #1
    Closed Accounts Posts: 1,040 ✭✭✭


    Hi, i have a csv file saved on my desktop and i want to print its contents.

    this is the error i get -
    [Errno 2] No such file or directory: dates.csv

    The problem is python cannot find the csv file?


Comments

  • Registered Users Posts: 851 ✭✭✭TonyStark


    Hi, i have a csv file saved on my desktop and i want to print its contents.

    this is the error i get -
    [Errno 2] No such file or directory: dates.csv

    The problem is python cannot find the csv file?

    Where is the program located? On your desktop?


  • Closed Accounts Posts: 1,040 ✭✭✭Scrappychimow


    TonyStark wrote: »
    Where is the program located? On your desktop?

    yes


  • Closed Accounts Posts: 1,040 ✭✭✭Scrappychimow


    its fine solved it.


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    For future reference, you won't get much help if you don't post your code.


  • Registered Users Posts: 851 ✭✭✭TonyStark


    Be handy to tell us how you solved it as well. You don't need to be specific, but some sort of followup would be useful.


  • Advertisement
  • Closed Accounts Posts: 1,040 ✭✭✭Scrappychimow


    I put the csv file in the same folder as i put the saved python program from the shell.


  • Registered Users Posts: 2,015 ✭✭✭Colonel Panic


    Some helpful path functions in Python: https://docs.python.org/2/library/os.path.html
    If you want to specify the file from the command line: https://docs.python.org/2/howto/argparse.html


  • Hosted Moderators Posts: 3,331 ✭✭✭Splinter


    you can also specify the full path directly once you remember to escape the / in the file path.

    e.g.

    for file in os.listdir('c:\\users\\Splinter\\Desktop'):


Advertisement