Solved

segregating a list into two lists

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

910 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

23 Experts available now in Live!

Get 1:1 Help Now