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
  Make entire script run again every 45 mo NDillard 0 317 Jan-23-2024, 09:40 PM
Last Post: NDillard
  Trying to make a board with turtle, nothing happens when running script Quascia 3 658 Nov-01-2023, 03:11 PM
Last Post: deanhystad
  Running script with subprocess in another directory paul18fr 1 3,709 Jan-20-2023, 02:33 PM
Last Post: paul18fr
  Read directory listing of files and parse out the highest number? cubangt 5 2,338 Sep-28-2022, 10:15 PM
Last Post: Larz60+
  Make console show after script was built with Pyinstaller --NOCONSOLE? H84Gabor 0 1,208 May-05-2022, 12:32 PM
Last Post: H84Gabor
  How to read python shortcut target profile directory of Chrome Ink file sunny9495 1 1,656 Apr-12-2022, 06:12 PM
Last Post: sunny9495
  Make my py script work only on 1 compter tomtom 14 3,824 Feb-20-2022, 06:19 PM
Last Post: DPaul
  python keeps opening script directory Tyrel 5 2,997 Aug-06-2021, 10:43 PM
Last Post: snippsat
  problem with sphinx and file directory in script kiyoshi7 0 2,285 Mar-11-2021, 03:52 PM
Last Post: kiyoshi7
  read the first line in my script chubbychub 1 1,749 Nov-09-2020, 03:18 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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