Jump to content

  •  

Photo

Filtering a field for text files only


  • Please log in to reply
15 replies to this topic

#1 K1200  old hand

K1200
  • Members
  • 588 posts
  • FM Application:11 Advance
  • Platform:Windows 7
  • Skill Level:Intermediate
  • Time Online: 20d 11h 23m 28s

Posted 25 February 2012 - 10:56 AM

I'm populating a value list from a field containing all the file names in a directory (hundreds of values). I need to filter it to only show files with a .txt or .TXT extension. I can do it using a loop in a script, but I'm hoping someone can point out a simple calculation technique.

BTW, I've looked at a couple of functions on BrianDunning.com and found them too involved for this simple case. Others may eventually look at my code! Plus, I'd generally like to know how to filter fields for other reasons.

Thanks for any help.
  • 0

#2 Raybaudi  ChindoguMaker

Raybaudi
  • Members
  • 3,216 posts
  • LocationRome, Italy
  • FM Application:12 Advance
  • Platform:Windows XP
  • Skill Level:Intermediate
  • Time Online: 47d 1h 23m 11s

Posted 25 February 2012 - 11:16 AM

hundreds of values in a field ( 1 record ) or a value for each record ?
  • 0
Daniele
--------------------------------
I'm sorry for my English

#3 K1200  old hand

K1200
  • Members
  • 588 posts
  • FM Application:11 Advance
  • Platform:Windows 7
  • Skill Level:Intermediate
  • Time Online: 20d 11h 23m 28s

Posted 25 February 2012 - 11:27 AM

Hundreds of file names in a single field ... each one a value ... as returned by a plug-in's list folder function.
  • 0

#4 Raybaudi  ChindoguMaker

Raybaudi
  • Members
  • 3,216 posts
  • LocationRome, Italy
  • FM Application:12 Advance
  • Platform:Windows XP
  • Skill Level:Intermediate
  • Time Online: 47d 1h 23m 11s

Posted 25 February 2012 - 01:05 PM

Using CustomList ( )* by Agnes Barouh, the calculation will be as simple as:

CustomList ( 1 ; ValueCount ( text ) ;
"If ( Right ( GetValue ( text ; [n] ) ; 4 ) = \".txt\" ; GetValue ( text ; [n] ) )"
)

* http://www.briandunning.com/cf/868


You could even try to use recursion with an unstored calculation field ( name it "result" ), looping with itself.

Let([
T = yourTextField ;
$i_InnerRecursion = $i_InnerRecursion + 1
];
Case(
Right ( GetValue ( T ; $i_InnerRecursion ) ; 4 ) = ".txt" and $i_InnerRecursion ≤ ValueCount ( T ) ; List ( GetValue ( T ; $i_InnerRecursion ) ; result ) ;
$i_InnerRecursion ≤ ValueCount ( T ) ; result ;
Let ( $i_InnerRecursion = "" ; "" )
)
)
  • 0
Daniele
--------------------------------
I'm sorry for my English

#5 comment  consultant

comment
  • Members
  • 24,104 posts
  • Time Online: 325d 13h 43m 45s

Posted 25 February 2012 - 03:32 PM

How about a non-recursive one?

FilterValues (
listOfFiles ;
Substitute ( listOfFiles & ¶ ; [ ".txt" & ¶ ; "§" ] ; [ ".TXT" & ¶ ; "∆" ] ; [ ¶ ; "±¶" ] ; [ "§" ; ".txt" & ¶ ] ; [ "∆" ; ".TXT" & ¶ ] )
)
  • 1

#6 LaRetta   Lifelong FM Student

LaRetta
  • Members
  • 9,749 posts
  • LocationOregon
  • FM Application:13 Advance
  • Platform:Mac OS X Mavericks
  • Time Online: 213d 4h 17m 44s

Posted 25 February 2012 - 06:37 PM

Now this rivals your Tower of Hanoi calculation and your laminated calculation as well. Absolute genius, watching the switch work through it.

Is there any reason (other than clarity) that you listed it as ".TXT" & ¶ instead of "TXT¶" ?
  • 0
Each assumption is an educated guess, a likely condition or event, presumed known and true in the absence of absolute certainty.

#7 comment  consultant

comment
  • Members
  • 24,104 posts
  • Time Online: 325d 13h 43m 45s

Posted 25 February 2012 - 06:55 PM

Is there any reason (other than clarity) that you listed it as ".TXT" & ¶ instead of "TXT¶" ?


Well, the idea is to generalize it into suffix & ¶

BTW, at least part of the credit goes to Agnes Barouh.


Now this rivals your Tower of Hanoi calculation


I have a Tower of Hanoi calculation?
  • 0

#8 imoree  master

imoree
  • Members
  • 384 posts
  • LocationBahamas
  • FM Application:11 Advance
  • Platform:Mac OS X Lion
  • Skill Level:Intermediate
  • Membership:TechNet
  • Time Online: 50d 11h 26m 39s

Posted 26 February 2012 - 02:48 AM

What are these icons?

"§" "∆" & why are you using them in the calculation? thanks

-i
  • 0

#9 comment  consultant

comment
  • Members
  • 24,104 posts
  • Time Online: 325d 13h 43m 45s

Posted 26 February 2012 - 02:57 AM

They are characters assumed not to be used in listOfFiles.
  • 0

#10 imoree  master

imoree
  • Members
  • 384 posts
  • LocationBahamas
  • FM Application:11 Advance
  • Platform:Mac OS X Lion
  • Skill Level:Intermediate
  • Membership:TechNet
  • Time Online: 50d 11h 26m 39s

Posted 26 February 2012 - 03:37 AM

They are characters assumed not to be used in listOfFiles.

thanks
  • 0

#11 Raybaudi  ChindoguMaker

Raybaudi
  • Members
  • 3,216 posts
  • LocationRome, Italy
  • FM Application:12 Advance
  • Platform:Windows XP
  • Skill Level:Intermediate
  • Time Online: 47d 1h 23m 11s

Posted 26 February 2012 - 01:07 PM

How about a non-recursive one?


Ahh, the power of FilterValues ( ) !
Well done.
  • 0
Daniele
--------------------------------
I'm sorry for my English

#12 LaRetta   Lifelong FM Student

LaRetta
  • Members
  • 9,749 posts
  • LocationOregon
  • FM Application:13 Advance
  • Platform:Mac OS X Mavericks
  • Time Online: 213d 4h 17m 44s

Posted 26 February 2012 - 03:00 PM

I have a Tower of Hanoi calculation?


Well that is what I named your calculation where you first used §§ within Substitute() to play switch-a-roo with the values in this way. Your formula reminded me of Tower of Hanoi http://www.cut-the-k...nce/hanoi.shtml which I had first learned of from a great post here
http://attic.fmforum...earch/1/#187899.

Unfortunately, I could not find that original post where you first presented it and I sure tried. I believe it was around 2007. If you didn't have a billion posts on all the forums it would be easier but please continue making it difficult for us to keep up with your work. You would think I would remember the exact calculation of yours but it was not the formula that mattered in that instance but rather the power of using Substitute() to re-work values in such a pretty, recursive fashion. Tower of Hanoi is pretty cool.

I miss Søren. He always added so much flavor (and sometimes heat, LOL) to a discussion.
  • 0
Each assumption is an educated guess, a likely condition or event, presumed known and true in the absence of absolute certainty.

#13 Vaughan  Mostly Harmless

Vaughan
  • Moderators
  • 10,294 posts
  • LocationSydney, Australia
  • FM Application:13 Advance
  • FMGo:iPhone / iPod Touch, iPad
  • Platform:Cross Platform
  • Skill Level:Expert
  • Certification:8, 9, 10, 11
  • Membership:TechNet
  • Time Online: 4d 9h 48s

Posted 26 February 2012 - 03:41 PM

I miss Søren. He always added so much flavor (and sometimes heat, LOL) to a discussion.


Yes. It was from reading his posts that I developed an enthusiasm for cyrptology. He certainly had a way with words. :)
  • 0
Vaughan Bromfield
Sydney, Australia

Please post questions to the Forum, not directly to me. Back-up your files before making changes!

Whenever I hear the term "popular culture" I reach for my Iridium Q-36 Space Modulator.

#14 comment  consultant

comment
  • Members
  • 24,104 posts
  • Time Online: 325d 13h 43m 45s

Posted 26 February 2012 - 04:32 PM

Your formula reminded me of Tower of Hanoi


I see - but the Tower of Hanoi is something much more complex. This is just 'cover the furniture while I spray-paint'.
  • 0

#15 steigrafx  enthusiast

steigrafx
  • Members
  • 152 posts
  • FM Application:11 Advance
  • Platform:Windows XP
  • Skill Level:Novice
  • Time Online: 1d 9h 21m 56s

Posted 26 February 2012 - 05:20 PM

LaRetta, I believe your original "Tower of Hanoi" post is here:

http://filemakertoda...for-final-comma

"Thanks, Michael. What a pretty switch-a-roo! I'm naming your calc Tower of Hanoi."
  • 0

#16 LaRetta   Lifelong FM Student

LaRetta
  • Members
  • 9,749 posts
  • LocationOregon
  • FM Application:13 Advance
  • Platform:Mac OS X Mavericks
  • Time Online: 213d 4h 17m 44s

Posted 26 February 2012 - 06:10 PM

Then I'm mistaken because that wasn't the calc I was thinking of. But thank you for finding it anyway!!

Well, I think many calculations are gorgeous and it's hard to find a favorite! :laugh2:
  • 0
Each assumption is an educated guess, a likely condition or event, presumed known and true in the absence of absolute certainty.




FMForum Advertisers