Python Forum
Browse and build a list of folder paths using recursion
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Browse and build a list of folder paths using recursion
#5
(Apr-22-2021, 01:53 PM)ibreeden Wrote: I am not familiar with Jython, so the objects you are using are a bit foreign to me. But I see you are calling "BrowseServer(server, nodeId)" and it seems to work. So nodeID contains a path. Can you try to change "print(nodeName)" on line 15 to "print(nodeId)"? Does that show a useful path?

There's no need to print the nodeID because it'll be the same outcome, except it'll be a string integer for example: "122344".
We use nodeID to identify the folder we are going into because the nodeName is not enough and that's how the opcServer identifies the different element types within its structure.

You don't have to worry about the objects or jython because I can assure you the objects that are being used are going in/out of the server tree in the right path because originally I used a nested for loop but I could only go so far in the tree but the output was in the correct order as I expected . I just couldn't go deeper in the tree that's what brought me to use recursion? Take a look at the code below:

[Image: CSGUM.png]


The output is what I want, but I need to go deeper in the tree because there's more folders?
You can take a look at the OPC Browse pane in the image towards the left and then you can look under the "bacnet Port" folder and see more folders I need to grab but the nested for loop is not enough?
Reply


Messages In This Thread
RE: Browse and build a list of folder paths using recursion - by Ultrainstinct_5 - Apr-23-2021, 05:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Compare folder A and subfolder B and display files that are in folder A but not in su Melcu54 3 730 Jan-05-2024, 05:16 PM
Last Post: Pedroski55
Question Keyword to build list from list of objects? pfdjhfuys 3 1,734 Aug-06-2022, 11:39 PM
Last Post: Pedroski55
  python-docx regex : Browse the found words in turn from top to bottom Tmagpy 0 1,625 Jun-27-2022, 08:45 AM
Last Post: Tmagpy
  pdf2image, poppler and paths jehoshua 18 16,063 Jun-14-2022, 06:38 AM
Last Post: jehoshua
  Windows paths issue otalado 3 1,574 May-29-2022, 09:11 AM
Last Post: snippsat
  Compare filename with folder name and copy matching files into a particular folder shantanu97 2 4,724 Dec-18-2021, 09:32 PM
Last Post: Larz60+
  Move file from one folder to another folder with timestamp added end of file shantanu97 0 2,581 Mar-22-2021, 10:59 AM
Last Post: shantanu97
  automatically get absolute paths oclmedyb 1 2,231 Mar-11-2021, 04:31 PM
Last Post: deanhystad
  Using recursion instead of for loops / list comprehension Drone4four 4 3,300 Oct-10-2020, 05:53 AM
Last Post: ndc85430
  chkFile with absolute paths JarredAwesome 7 3,153 Sep-21-2020, 03:51 AM
Last Post: bowlofred

Forum Jump:

User Panel Messages

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