Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get list element number that contains 'csv'

Status
Not open for further replies.

Keendev

Technical User
Jan 23, 2006
106
0
0
PH

Hi Guys,

Need help on this.

I have a list. And inside my list is "one.doc,two,three,four.csv,five.csv "
ex : filelist = one.doc,two,three,four.csv,five.csv


How do I get element number that contains ".csv"?
For this example I should get element 4 and 5.
Is there a better CF function for this?

Basically I need to get the files that are .csv for validation.

What i did was i put it on a loop,but running loop may get problem specially if there are hundreds of files.

Code:
 <CFSET numLoop = #Listlen(aList)#>

<cfoutput>numLoop :#numLoop#</cfoutput> <br>

<cfoutput>
<cfloop  index="i" from="1" to="#numLoop#">

element:  #ListContains(filelist, ".csv")#
	
</cfloop>
</cfoutput>
Dont know if this is the correct approach, need some advice.

Thanks in advance.
 
How is the list generated and what are you ultimately doing with the results? I am just wondering if you really need the index numbers or just the values?

What version of CF are you using?



----------------------------------
 
Hi,

im getting the files from a certain directory and putting it on a list

Code:
<cfdirectory directory="#path#" name="newFolderDir" sort="name ASC, size DESC">

 <cfloop query="newFolderDir" >
		 <CFSET File_list = ListAppend(File_list, #Name#)>
 </cfloop>

But I need also to get the files that is .csv files only.


 

Hi again =)

Im using Cf 6.1 MX.
And need index numbers and the values?

thanks
 
i.e. Use a QoQ on your newFolderDir query. Not tested, but something along these lines

<cfquery name="findCSV" dbtype="query">
SELECT Name
FROM newFolderDir
WHERE LOWER(Name) LIKE '%.csv'
</cfquery>

Or if you only need the .csv files to begin with, use a filter with cfdirectory.


----------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top