cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-50377%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EOpen%20files%20(lookup%20characters%20from%20file%20name)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-50377%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EAll%2C%3CBR%20%2F%3EI%20am%20trying%20to%20open%20files%20in%20a%20folder%20by%20searching%20characters%20of%20file%20name%20based%20on%20user%20input.%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3E%2F*%20Input%20values%20in%203%20columns%20by%20user.%20eg%20of%20file%20name%3A%20ABC_12_XYZ.%20User%20will%20input%20ABC%20in%201st%20column%2C%2012%20in%20second%20col%20and%20XYZ%20in%203rd%20column.%20all%20three%20should%20match%20in%20a%20row%20for%20selecting%20the%20file.%20There%20could%20be%20100's%20of%20files%20(unique%20name)%20in%20the%20folder.%20User%20will%20input%20all%20that%20he%20wants%20to%20select%20from%20folder%20into%20input%20file.%20The%20file%20name%20search%20is%20limited%20to%2010%20characters%20from%20beginning%20of%20file%20name.%20The%20code%20is%20getting%20stuck%20somewhere%20in%20loop*%2F%0A%0A%2F%2FScript%20------%0A%0ARetrieve%20%3D%20Open(%20%22C%3A%5C*%5Cinputfile.jmp%22%20)%3B%0A%E3%80%80%0Ax%20%3D%20Column(%20Retrieve%2C%20%22Col1%22%20)%20%26lt%3B%26lt%3B%20Get%20Values%3B%0Ay%20%3D%20Column(%20Retrieve%2C%20%22Col2%22%20)%20%26lt%3B%26lt%3B%20Get%20Values%3B%0Az%20%3D%20Column(%20Retrieve%2C%20%22Col3%22%20)%20%26lt%3B%26lt%3B%20Get%20Values%3B%0A%0A%E3%80%80%0A%2F%2F%20location%20of%20files%20which%20needs%20to%20be%20read%20from%20a%20folder%20based%20on%20user%20inputs.%0ASet%20Default%20Directory(%22C%3A%5Ctest%5C%22)%3B%0A%0AClose(%20Retrieve%2C%20NoSave%20)%3B%0A%0ACol1_search%20%3D%201%3B%0ACol2_search%20%3D%201%3B%0ACount%20%3D%200%3B%0A%E3%80%80%0AFor(%20i%20%3D%201%2C%20i%20%26lt%3B%3D%20N%20Items(%20files%20)%2C%20i%2B%2B%2C%0AFor(%20j%20%3D%201%2C%20j%20%26lt%3B%3D%20N%20Items(%20z%20)%2C%20j%2B%2B%2C%0AIf(%20Contains(%20files%5Bi%5D%2C%20z%5Bj%5D%20)%2C%0AIf(%20Col1_search%20%3D%3D%201%2C%0AIf(%20(Contains(%20files%5Bi%5D%2C%20z%5Bj%5D%20)%20%26amp%3B%20Contains(%20Left(%20files%5Bi%5D%2C%2010%20)%2C%20x%5Bj%5D%20))%20%26gt%3B%200%2C%0A%0A%0AIf(%20Col2_Search%20%3D%3D%201%2C%0AIf(%0A((Contains(%20files%5Bi%5D%2C%20z%5Bj%5D%20)%20%26amp%3B%20Contains(%20Left(%20files%5Bi%5D%2C%2010%20)%2C%20x%5Bj%5D%20))%20%26gt%3B%200)%20%26amp%3B%20(Contains(%20Left(%20files%5Bi%5D%2C%2010%20)%2C%20y%5Bj%5D%20)%20%26gt%3B%20(Contains(%20Left(%20files%5Bi%5D%2C%2010%20)%2C%20x%5Bj%5D%20)))%2C%0AOpen(%20files%5Bi%5D%20)%3B%0ACount%2B%2B%3B%0A)%2C%0AOpen(%20files%5Bi%5D%20)%3B%0A%0A%0AIf(%20Count%20%3D%3D%20N%20Items(%20z%20)%2C%0ABreak()%3B%0A%0A)%3B%0A%0A)%0A)%0A%0A)%2C%0AOpen(%20files%5Bi%5D%20)%0A%0A)%0A%0A)%3B%0A%0A)%3B%0A%0A%0AopenDTs%20%3D%20%7B%7D%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-50485%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Open%20files%20(lookup%20characters%20from%20file%20name)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-50485%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F18880%22%20target%3D%22_blank%22%3E%40Uday%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20able%20to%20figure%20out%20the%20issue.%20The%20source%20is%2018%20characters%20and%20pattern%20is%20entire%20string.%3C%2FP%3E%3CP%3EI%20added%20one%20more%20loop%20to%20perform%20lookup%20of%20input%20files%20against%20all%20files%20as%20below.%3C%2FP%3E%3CP%3EAppreciate%20your%20quick%20responses!%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%230000dd%22%20face%3D%22Consolas%22%20size%3D%222%22%3EFor%3C%2FFONT%3E%3CSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E(%3C%2FFONT%3E%3C%2FSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%20i%20%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%3D%3C%2FFONT%3E%20%3CSTRONG%3E%3CFONT%20color%3D%22%23008080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E1%3C%2FFONT%3E%3C%2FSTRONG%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%2C%3C%2FFONT%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%20i%20%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%26lt%3B%3D%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000dd%22%20face%3D%22Consolas%22%20size%3D%222%22%3EN%20Items%3C%2FFONT%3E%3CSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E(%3C%2FFONT%3E%3C%2FSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%20Files%20%3CSTRONG%3E)%3C%2FSTRONG%3E%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%2C%3C%2FFONT%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%20i%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%2B%2B%2C%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%230000dd%22%20face%3D%22Consolas%22%20size%3D%222%22%3EFor%3C%2FFONT%3E%3CSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E(%3C%2FFONT%3E%3C%2FSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%20j%20%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%3D%3C%2FFONT%3E%20%3CSTRONG%3E%3CFONT%20color%3D%22%23008080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E1%3C%2FFONT%3E%3C%2FSTRONG%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%2C%3C%2FFONT%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%20j%20%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%26lt%3B%3D%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000dd%22%20face%3D%22Consolas%22%20size%3D%222%22%3EN%20Items%3C%2FFONT%3E%3CSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E(%3C%2FFONT%3E%3C%2FSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%20x%20%3CSTRONG%3E)%3C%2FSTRONG%3E%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%2C%3C%2FFONT%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%20j%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%2B%2B%2C%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%230000dd%22%20face%3D%22Consolas%22%20size%3D%222%22%3EIf%3C%2FFONT%3E%3CSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E(%3C%2FFONT%3E%3C%2FSTRONG%3E%20%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E!%3C%2FFONT%3E%3CFONT%20color%3D%22%230000dd%22%20face%3D%22Consolas%22%20size%3D%222%22%3EIs%20Missing%3C%2FFONT%3E%3CSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E(%3C%2FFONT%3E%3C%2FSTRONG%3E%20%3CFONT%20color%3D%22%230000dd%22%20face%3D%22Consolas%22%20size%3D%222%22%3ERegex%3C%2FFONT%3E%3CSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E(%3C%2FFONT%3E%3C%2FSTRONG%3E%20%3CFONT%20color%3D%22%230000dd%22%20face%3D%22Consolas%22%20size%3D%222%22%3ESubstr%3C%2FFONT%3E%3CSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E(%3C%2FFONT%3E%3C%2FSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%20Files%3CSTRONG%3E%5B%3C%2FSTRONG%3Ei%3CSTRONG%3E%5D%3C%2FSTRONG%3E%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%2C%3C%2FFONT%3E%20%3CSTRONG%3E%3CFONT%20color%3D%22%23008080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E1%3C%2FFONT%3E%3C%2FSTRONG%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%2C%3C%2FFONT%3E%20%3CSTRONG%3E%3CFONT%20color%3D%22%23008080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E18%3C%2FFONT%3E%3C%2FSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%20%3CSTRONG%3E)%3C%2FSTRONG%3E%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%2C%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000dd%22%20face%3D%22Consolas%22%20size%3D%222%22%3EChar%3C%2FFONT%3E%3CSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E(%3C%2FFONT%3E%3C%2FSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%20x%3CSTRONG%3E%5B%3C%2FSTRONG%3Ej%3CSTRONG%3E%5D%3C%2FSTRONG%3E%20%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%7C%7C%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23800080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%22_%22%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%7C%7C%3C%2FFONT%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%20y%3CSTRONG%3E%5B%3C%2FSTRONG%3Ej%3CSTRONG%3E%5D%3C%2FSTRONG%3E%20%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%7C%7C%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23800080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%22_%22%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%7C%7C%3C%2FFONT%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%20z%3CSTRONG%3E%5B%3C%2FSTRONG%3Ej%3CSTRONG%3E%5D%3C%2FSTRONG%3E%20%3CSTRONG%3E)%3C%2FSTRONG%3E%20%3CSTRONG%3E)%3C%2FSTRONG%3E%20%3CSTRONG%3E)%3C%2FSTRONG%3E%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%2C%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%230000dd%22%20face%3D%22Consolas%22%20size%3D%222%22%3EOpen%3C%2FFONT%3E%3CSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E(%3C%2FFONT%3E%3C%2FSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%20TestDir%20%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%7C%7C%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23800080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%22%5C%22%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%7C%7C%3C%2FFONT%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%20Files%3CSTRONG%3E%5B%3C%2FSTRONG%3Ei%3CSTRONG%3E%5D%3C%2FSTRONG%3E%20%3CSTRONG%3E)%3C%2FSTRONG%3E%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%3B%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%230000dd%22%20face%3D%22Consolas%22%20size%3D%222%22%3EBreak%3C%2FFONT%3E%3CSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E()%3C%2FFONT%3E%3C%2FSTRONG%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%3B%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%3CSTRONG%3E)%3C%2FSTRONG%3E%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%3B%2C%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%3CSTRONG%3E)%3C%2FSTRONG%3E%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%3B%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-50399%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Open%20files%20(lookup%20characters%20from%20file%20name)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-50399%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20Open(%20%22%24SAMPLE_DATA%2FCities.jmp%22%20)%3B%20%2F%2F%20Open%20Sample%20Data%20%0A%0Adt%20%26lt%3B%26lt%3B%20Select%20Where(!IsMissing(Regex(Char(%3Acity)%2C%22ALB%22)))%3B%20%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EYou%20dont%20need%20to%20use%20%22Contains%22%20function.%20Look%20at%20the%20example%20shown%20above.%20If%20you%20wanted%20to%20just%20search%20for%2018%20characters%2C%20of%20the%20file%20name%2C%20then%20that%20will%20need%20to%20be%20extracted%20using%20the%20Substr%20function%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20Open(%20%22%24SAMPLE_DATA%2FCities.jmp%22%20)%3B%20%2F%2F%20Open%20Sample%20Data%20%0A%0Adt%20%26lt%3B%26lt%3B%20Select%20Where(!IsMissing(Regex(Char(%3Acity)%2CSubstr(%22ALBANY%22%2C1%2C3))))%3B%20%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-50398%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Open%20files%20(lookup%20characters%20from%20file%20name)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-50398%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%3CSTRONG%3EHere%20is%20copy%20of%20log%20-%20%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20following%20script%2C%20error%20marked%20by%20%2F*%23%23%23*%2F%3C%2FP%3E%3CP%3EFor(%20i%20%3D%201%2C%20i%20%26lt%3B%3D%20N%20Items(%20Files%20)%2C%20i%2B%2B%2C%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%3CSTRONG%3EIf(%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E!Is%20Missing(%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3ERegex%2F*%23%23%23*%2F(Char(%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3Ex%20%7C%7C%20%2F*%23%23%23*%2F%22_%22%20%7C%7C%20%2F*%23%23%23*%2Fy%20%7C%7C%20%2F*%23%23%23*%2F%22_%22%20%7C%7C%20%2F*%23%23%23*%2Fz%2F*%23%23%23*%2F%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E)%2C%20Files%5Bi%5D)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E)%2C%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3EOpen(%20TestDir%20%7C%7C%20%22%5C%22%20%7C%7C%20Files%5Bi%5D%20)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20reason%20why%20i%20am%20using%20contains%20is%20to%20look%20for%2018%20characters%20from%20file%20name%20which%20could%20be%2040characters%20long.%3C%2FP%3E%3CP%3EI%20am%20not%20sure%20if%20i%20am%20doing%20it%20right.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-50395%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Open%20files%20(lookup%20characters%20from%20file%20name)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-50395%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F8941%22%20target%3D%22_blank%22%3E%40CG%3C%2FA%3E%2C%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20Can%20you%20share%20what%20the%20error%20is%26nbsp%3B%20%3F%20A%20copy%20of%20your%20log%20%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BAlso%2C%20I%20don't%20follow%20why%20you%20are%20adding%20a%20Contains%20%3F%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20The%20second%20argument%20should%20be%20the%20term%20you%20are%20trying%20to%20match%20against%20%3A%26nbsp%3B%3CBR%20%2F%3ESo%20%2C%20if%20you%20were%20trying%20to%20look%20for%20your%20name%2C%20it%20would%20like%20%3A%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EIf%20(!IsMissing(Regex(Char(x%20%7C%7C%20%22_%22%20%7C%7C%20y%20%7C%7C%20%22_%22%7C%7Cz)%2C%22CG%22))%2C%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-50394%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Open%20files%20(lookup%20characters%20from%20file%20name)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-50394%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3Ei%20am%20looking%20for%201st%2018%20characters%20in%20file%20name%3C%2FP%3E%3CP%3Ei%20modified%20below%20loop%20and%20added%20condition%20to%20look%20for%2018%20characters%20upto%20z%20for%20file%20name%20x_y_z1234%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%230000dd%22%20face%3D%22Consolas%22%20size%3D%222%22%3Efor%3C%2FFONT%3E%3CSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E(%3C%2FFONT%3E%3C%2FSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3Ei%20%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%3D%3C%2FFONT%3E%20%3CSTRONG%3E%3CFONT%20color%3D%22%23008080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E1%3C%2FFONT%3E%3C%2FSTRONG%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%2C%3C%2FFONT%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%20i%20%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%26lt%3B%3D%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000dd%22%20face%3D%22Consolas%22%20size%3D%222%22%3EN%20Items%3C%2FFONT%3E%3CSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E(%3C%2FFONT%3E%3C%2FSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3EFiles%3CSTRONG%3E)%3C%2FSTRONG%3E%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%2C%3C%2FFONT%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%20i%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%2B%2B%2C%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%230000dd%22%20face%3D%22Consolas%22%20size%3D%222%22%3EIf%3C%2FFONT%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%20%3CSTRONG%3E(%3C%2FSTRONG%3E%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E!%3C%2FFONT%3E%3CFONT%20color%3D%22%230000dd%22%20face%3D%22Consolas%22%20size%3D%222%22%3EIsMissing%3C%2FFONT%3E%3CSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E(%3C%2FFONT%3E%3C%2FSTRONG%3E%3CFONT%20color%3D%22%230000dd%22%20face%3D%22Consolas%22%20size%3D%222%22%3ERegex%3C%2FFONT%3E%3CSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E(%3C%2FFONT%3E%3C%2FSTRONG%3E%3CFONT%20color%3D%22%230000dd%22%20face%3D%22Consolas%22%20size%3D%222%22%3EChar%3C%2FFONT%3E%3CSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E(%3C%2FFONT%3E%3C%2FSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3Ex%20%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%7C%7C%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23800080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%22_%22%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%7C%7C%3C%2FFONT%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%20y%20%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%7C%7C%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23800080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%22_%22%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%7C%7C%3C%2FFONT%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3Ez%3CSTRONG%3E)%3C%2FSTRONG%3E%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%2C%3C%2FFONT%3E%3CFONT%20color%3D%22%230000dd%22%20face%3D%22Consolas%22%20size%3D%222%22%3Econtains%3C%2FFONT%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%20%3CSTRONG%3E(%3C%2FSTRONG%3E%3C%2FFONT%3E%3CFONT%20color%3D%22%230000dd%22%20face%3D%22Consolas%22%20size%3D%222%22%3ELeft%3C%2FFONT%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%20%3CSTRONG%3E(%3C%2FSTRONG%3EFiles%3CSTRONG%3E%5B%3C%2FSTRONG%3Ei%3CSTRONG%3E%5D)%3C%2FSTRONG%3E%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%2C%3C%2FFONT%3E%3CSTRONG%3E%3CFONT%20color%3D%22%23008080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E18%3C%2FFONT%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E))%3C%2FFONT%3E%3C%2FSTRONG%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%2C%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%230000dd%22%20face%3D%22Consolas%22%20size%3D%222%22%3EOpen%3C%2FFONT%3E%3CSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E(%3C%2FFONT%3E%3C%2FSTRONG%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3ETestDir%20%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%7C%7C%3C%2FFONT%3E%3CFONT%20color%3D%22%23800080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%22%5C%22%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%7C%7C%3C%2FFONT%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%20Files%3CSTRONG%3E%5B%3C%2FSTRONG%3Ei%3CSTRONG%3E%5D)%3C%2FSTRONG%3E%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%3B%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%3CSTRONG%3E)%3C%2FSTRONG%3E%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%2C%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%3CSTRONG%3E)%3C%2FSTRONG%3E%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%3B%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%3CSTRONG%3E)%3C%2FSTRONG%3E%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3E%3B%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Consolas%22%20size%3D%222%22%3EBut%20i%20still%20get%20error%20-%20%3C%2FFONT%3E%3C%2FP%3E%3CP%3EFor(%20i%20%3D%201%2C%20i%20%26lt%3B%3D%20N%20Items(%20Files%20)%2C%20i%2B%2B%2C%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Consolas%22%20size%3D%222%22%3E%3CSTRONG%3EIf%2F*%23%23%23*%2F(Is%20Missing(%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3ERegex(%20Char(%20x%20%7C%7C%20%22_%22%20%7C%7C%20y%20%7C%7C%20%22_%22%20%7C%7C%20z%20)%2C%20Contains(%20Left(%20Files%5Bi%5D%20)%2C%2018%20)%20)%2C%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3EOpen(%20TestDir%20%7C%7C%20%22%5C%22%20%7C%7C%20Files%5Bi%5D%20)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E))%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-50386%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Open%20files%20(lookup%20characters%20from%20file%20name)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-50386%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F8941%22%20target%3D%22_blank%22%3E%40CG%3C%2FA%3E%2C%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20Is%20it%20fair%20to%20assume%20that%20in%20your%20case%2C%20the%20file%20format%20will%20always%20be%20ABC_12_XYZ%20(i.e.%20x_y_z)%20%3F%20If%20yes%2C%20an%20alternative%20and%20simpler%20way%20might%20be%20%3A%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ERetrieve%20%3D%20Open(%20%22C%3A%5C*%5Cinputfile.jmp%22%20)%3B%0A%E3%80%80%0Ax%20%3D%20Column(%20Retrieve%2C%20%22Col1%22%20)%20%26lt%3B%26lt%3B%20Get%20Values%3B%0Ay%20%3D%20Column(%20Retrieve%2C%20%22Col2%22%20)%20%26lt%3B%26lt%3B%20Get%20Values%3B%0Az%20%3D%20Column(%20Retrieve%2C%20%22Col3%22%20)%20%26lt%3B%26lt%3B%20Get%20Values%3B%0A%0AClose(Retrieve%2C%22No%20Save%22)%3B%20%0A%0ATestDir%20%3D%20%22C%3A%5Ctest%5C%22%3B%0AFiles%20%3D%20Files%20In%20Directory(TestDir)%3B%20%2F%2F%20Returns%20a%20list%20of%20files%20in%20the%20directory%0Afor(i%20%3D%201%2C%20i%20%26lt%3B%3D%20N%20Items(Files)%2C%20i%2B%2B%2C%0A%20%20%20%20%20%20%20If(!IsMissing(Regex(Char(x%20%7C%7C%20%22_%22%20%7C%7C%20y%20%7C%7C%20%22_%22%7C%7Cz)%2CFiles%5Bi%5D))%2C%0A%20%20%20Open(TestDir%20%7C%7C%22%5C%22%20%7C%7C%20Files%5Bi%5D)%3B%20%0A%20%20%20%20%20%20%20%20%20)%3B%20%0A%20%20%20%20)%3B%20%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
CG
CG
Level III

Open files (lookup characters from file name)

All,
I am trying to open files in a folder by searching characters of file name based on user input.

/* Input values in 3 columns by user. eg of file name: ABC_12_XYZ. User will input ABC in 1st column, 12 in second col and XYZ in 3rd column. all three should match in a row for selecting the file. There could be 100's of files (unique name) in the folder. User will input all that he wants to select from folder into input file. The file name search is limited to 10 characters from beginning of file name. The code is getting stuck somewhere in loop*/

//Script ------

Retrieve = Open( "C:\*\inputfile.jmp" );
 
x = Column( Retrieve, "Col1" ) << Get Values;
y = Column( Retrieve, "Col2" ) << Get Values;
z = Column( Retrieve, "Col3" ) << Get Values;

 
// location of files which needs to be read from a folder based on user inputs.
Set Default Directory("C:\test\");

Close( Retrieve, NoSave );

Col1_search = 1;
Col2_search = 1;
Count = 0;
 
For( i = 1, i <= N Items( files ), i++,
For( j = 1, j <= N Items( z ), j++,
If( Contains( files[i], z[j] ),
If( Col1_search == 1,
If( (Contains( files[i], z[j] ) & Contains( Left( files[i], 10 ), x[j] )) > 0,


If( Col2_Search == 1,
If(
((Contains( files[i], z[j] ) & Contains( Left( files[i], 10 ), x[j] )) > 0) & (Contains( Left( files[i], 10 ), y[j] ) > (Contains( Left( files[i], 10 ), x[j] ))),
Open( files[i] );
Count++;
),
Open( files[i] );


If( Count == N Items( z ),
Break();

);

)
)

),
Open( files[i] )

)

);

);


openDTs = {};
1 ACCEPTED SOLUTION

Accepted Solutions
CG
CG
Level III

Re: Open files (lookup characters from file name)

@Uday

 

I am able to figure out the issue. The source is 18 characters and pattern is entire string.

I added one more loop to perform lookup of input files against all files as below.

Appreciate your quick responses!

Thanks!

 

For( i = 1, i <= N Items( Files ), i++,

For( j = 1, j <= N Items( x ), j++,

If( !Is Missing( Regex( Substr( Files[i], 1, 18 ), Char( x[j] || "_" || y[j] || "_" || z[j] ) ) ),

Open( TestDir || "\" || Files[i] );

Break();

);,

 

)

);

 

View solution in original post

6 REPLIES 6
uday_guntupalli
Level VIII

Re: Open files (lookup characters from file name)

@CG
      Is it fair to assume that in your case, the file format will always be ABC_12_XYZ (i.e. x_y_z) ? If yes, an alternative and simpler way might be : 

Retrieve = Open( "C:\*\inputfile.jmp" );
 
x = Column( Retrieve, "Col1" ) << Get Values;
y = Column( Retrieve, "Col2" ) << Get Values;
z = Column( Retrieve, "Col3" ) << Get Values;

Close(Retrieve,"No Save"); 

TestDir = "C:\test\";
Files = Files In Directory(TestDir); // Returns a list of files in the directory
for(i = 1, i <= N Items(Files), i++,
       If(!IsMissing(Regex(Char(x || "_" || y || "_"||z),Files[i])),
			Open(TestDir ||"\" || Files[i]); 
         ); 
    ); 
Best
Uday
CG
CG
Level III

Re: Open files (lookup characters from file name)

i am looking for 1st 18 characters in file name

i modified below loop and added condition to look for 18 characters upto z for file name x_y_z1234

 

for(i = 1, i <= N Items(Files), i++,

If (!IsMissing(Regex(Char(x || "_" || y || "_"||z),contains (Left (Files[i]),18)),

Open(TestDir ||"\" || Files[i]);

),

);

);

 

But i still get error -

For( i = 1, i <= N Items( Files ), i++,

If/*###*/(Is Missing(

 

Regex( Char( x || "_" || y || "_" || z ), Contains( Left( Files[i] ), 18 ) ),

Open( TestDir || "\" || Files[i] )

))

)

uday_guntupalli
Level VIII

Re: Open files (lookup characters from file name)

@CG
    Can you share what the error is  ? A copy of your log ? 

     Also, I don't follow why you are adding a Contains ? 
    The second argument should be the term you are trying to match against : 
So , if you were trying to look for your name, it would like : 

If (!IsMissing(Regex(Char(x || "_" || y || "_"||z),"CG")),



Best
Uday
CG
CG
Level III

Re: Open files (lookup characters from file name)

Here is copy of log -

 

In the following script, error marked by /*###*/

For( i = 1, i <= N Items( Files ), i++,

If(

!Is Missing(

Regex/*###*/(Char(

x || /*###*/"_" || /*###*/y || /*###*/"_" || /*###*/z/*###*/

), Files[i])

),

Open( TestDir || "\" || Files[i] )

)

)

 

 

The reason why i am using contains is to look for 18 characters from file name which could be 40characters long.

I am not sure if i am doing it right.

uday_guntupalli
Level VIII

Re: Open files (lookup characters from file name)

dt = Open( "$SAMPLE_DATA/Cities.jmp" ); // Open Sample Data 

dt << Select Where(!IsMissing(Regex(Char(:city),"ALB"))); 

You dont need to use "Contains" function. Look at the example shown above. If you wanted to just search for 18 characters, of the file name, then that will need to be extracted using the Substr function 

 

dt = Open( "$SAMPLE_DATA/Cities.jmp" ); // Open Sample Data 

dt << Select Where(!IsMissing(Regex(Char(:city),Substr("ALBANY",1,3)))); 

 

Best
Uday
CG
CG
Level III

Re: Open files (lookup characters from file name)

@Uday

 

I am able to figure out the issue. The source is 18 characters and pattern is entire string.

I added one more loop to perform lookup of input files against all files as below.

Appreciate your quick responses!

Thanks!

 

For( i = 1, i <= N Items( Files ), i++,

For( j = 1, j <= N Items( x ), j++,

If( !Is Missing( Regex( Substr( Files[i], 1, 18 ), Char( x[j] || "_" || y[j] || "_" || z[j] ) ) ),

Open( TestDir || "\" || Files[i] );

Break();

);,

 

)

);

 

Recommended Articles