Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Python import problem

  • 28-12-2014 08: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, Registered Users 2 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, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


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


  • Registered Users, Registered Users 2 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, Registered Users 2 Posts: 2,062 ✭✭✭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