Solved

segregating a list into two lists

Posted on 2016-07-22
4
53 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 15

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 15

Author Closing Comment

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

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now