Python Forum
Make the script read from any directory
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Make the script read from any directory
#1
Hi,

How could I make the script read the data from any directory,

I'd like to make it something like this,

product_path = os.path.join('product_path')
user_input_dir = input('\nPlease enter your directory path\n' + product_path)

It doesn't work,

Any suggestions please!
Reply
#2
this line is not doing anything
product_path = os.path.join('product_path')
this line will not produce the full path
user_input_dir = input('\nPlease enter your directory path\n' + product_path)
you want
user_input_dir = input('\nPlease enter your directory path\n')
product_path = os.path.join('product_path', user_input_dir) # assuming 'product path' is real dir
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Thanks a lot for your very nice explanation.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to make it so whatever I input into a script gets outputted on a different file spermatozwario 4 1,130 Nov-24-2024, 12:58 PM
Last Post: deanhystad
  Make entire script run again every 45 mo NDillard 0 889 Jan-23-2024, 09:40 PM
Last Post: NDillard
  Trying to make a board with turtle, nothing happens when running script Quascia 3 1,709 Nov-01-2023, 03:11 PM
Last Post: deanhystad
  Running script with subprocess in another directory paul18fr 1 11,832 Jan-20-2023, 02:33 PM
Last Post: paul18fr
  Read directory listing of files and parse out the highest number? cubangt 5 5,121 Sep-28-2022, 10:15 PM
Last Post: Larz60+
  Make console show after script was built with Pyinstaller --NOCONSOLE? H84Gabor 0 1,801 May-05-2022, 12:32 PM
Last Post: H84Gabor
  How to read python shortcut target profile directory of Chrome Ink file sunny9495 1 2,371 Apr-12-2022, 06:12 PM
Last Post: sunny9495
  Make my py script work only on 1 compter tomtom 14 6,239 Feb-20-2022, 06:19 PM
Last Post: DPaul
  python keeps opening script directory Tyrel 5 4,255 Aug-06-2021, 10:43 PM
Last Post: snippsat
  problem with sphinx and file directory in script kiyoshi7 0 2,893 Mar-11-2021, 03:52 PM
Last Post: kiyoshi7

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020