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 there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Python import problem

  • 28-12-2014 7: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,040 ✭✭✭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