Solved

segregating a list into two lists

Posted on 2016-07-22
4
70 Views
Last Modified: 2016-07-24
Hi I have the following list

D:\inetpub\wwwroot\July-2016\overview\05572YEF5.pdf D:\inetpub\wwwroot\July-2016\overview\45083AFX5.pdf D:\inetpub\wwwroot\July-2016\overview\46176PFG5.pdf D:\inetpub\wwwroot\July-2016\overview\38148DLN2.pdf D:\inetpub\wwwroot\July-2016\overview\38148DLQ5.pdf D:\inetpub\wwwroot\July-2016\overview\94986TA23.pdf D:\inetpub\wwwroot\March-2016\overview\FocusList.pdf D:\inetpub\wwwroot\March-2016\overview\38148DHS6.pdf D:\inetpub\wwwroot\March-2016\overview\38148DHK3.pdf D:\inetpub\wwwroot\March-2016\overview\38148DHV9.pdf 

Open in new window


I want to create the seperate lists for both, now tthere is a small catch. the July-2016 and March-2016 will be dynamic values i mean they can from jan or feb or 2015 so a single can contain multiple month and years combination.

i want them to be created as seperate lists so i can use them

how can i do, i tried few of the functions like listvenn or listcompare, none seems to matching what i am trying to do here from cflib
0
Comment
  • 2
  • 2
4 Comments
 
LVL 39

Expert Comment

by:gdemaria
ID: 41725319
You want to create two lists based on the value of the month-year?

First, loop through the file paths and pull out the fourth value which is the month/year
Create a structure whose elements are those dates, then add the file path to that structure.

<cfset newList = structNew()>
<cfloop index="aPath" list="#string#" delimiters=" ">
   <cfset theDate = listGetAt(aPath,4,"\/")>
   <cfif NOT structKeyExists(newList,theDate)>
      <cfset newList[theDate] = thePath>
   <cfelse> <!---- key already exists ---->
      <cfset newList[theDate] = listAppend(newList[theDate],thePath," ")>
   </cfif>
</cfloop>

<cfdump var="#newList#">

Open in new window

0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 41725402
ok, i tried running this and got error

first: what is string referred to: is it my list which i shared in the question

and 2. what is thePath, i am getting error on that
0
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 41725417
the string is the list of paths you have.

ThePath is a type o, it is the same variable in the index

<cfset newList = structNew()>
<cfset theString = "D:\inetpub\wwwroot\July-2016\overview\05572YEF5.pdf D:\inetpub\wwwroot\July-2016\overview\45083AFX5.pdf D:\inetpub\wwwroot\July-2016\overview\46176PFG5.pdf D:\inetpub\wwwroot\July-2016\overview\38148DLN2.pdf D:\inetpub\wwwroot\July-2016\overview\38148DLQ5.pdf D:\inetpub\wwwroot\July-2016\overview\94986TA23.pdf D:\inetpub\wwwroot\March-2016\overview\FocusList.pdf D:\inetpub\wwwroot\March-2016\overview\38148DHS6.pdf D:\inetpub\wwwroot\March-2016\overview\38148DHK3.pdf D:\inetpub\wwwroot\March-2016\overview\38148DHV9.pdf">
<cfloop index="aPath" list="#theString#" delimiters=" ">
   <cfset theDate = listGetAt(aPath,4,"\/")>
   <cfif NOT structKeyExists(newList,theDate)>
      <cfset newList[theDate] = aPath>
   <cfelse> <!---- key already exists ---->
      <cfset newList[theDate] = listAppend(newList[theDate],aPath," ")>
   </cfif>
</cfloop>

<cfdump var="#newList#">

Open in new window

0
 
LVL 16

Author Closing Comment

by:Gurpreet Singh Randhawa
ID: 41726554
Thanks for the quick response and good answer.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

805 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question