LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Any dll that does file content search like windows explorer?

Hello,
 
Does anybody know if a dll for Labview exists that allows searching for a specific string or pattern in a file?  The file does not have to be a text file.  It can be excel, or any other kind that windows recognize.
 
The way I'm doing it right now is to use activex to open an excel file, and search its contents using "match pattern", then close it again.  However, this is so slow compared to using windows explorer's "search word or phrase in file" attribute.  I'm only opening the file in the background and not opening any windows otherwise it will take 10 times as long.  Still, I believe its not as efficient as it should be.  I'm searching through thousands of files in a database.
 
Really appreciate it if someone can tell me if this dll exists or if there is a faster way of doing searches like this.
 
Thanks in advance.
0 Kudos
Message 1 of 9
(3,704 Views)

Hi Manny,

Proper file handling and, especially array (memory) allocation can make a huge difference.  But the diagram differences may be subtle.

Mind sharing the "slow" code?  Maybe you're missing a shortcut (or two). Smiley Happy

When they give imbeciles handicap-parking, I won't have so far to walk!
0 Kudos
Message 2 of 9
(3,697 Views)

hi there

you could use the windows command "find" with the system exec vi. type "find /?" on a command shell or see the windows online documentation. another solution would be to get a windows - version of "Grep". this is similar to "Find" but much more powerful (search of trees, regular expressions etc.)  

you could create a batch file out of the list of files to search through. the batch file could write its output to a logfile and your vi would then parse the logfile to get the results.
 
Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 3 of 9
(3,688 Views)
Thanks for the suggestions/recommendations.  I'll go try "grep" or "find".
 
Dunno if I can post my subvi's here.  It has a lot of referenced typedef controls and subvi's from several toolkits.   I'll try to gather them up in an llb so it'd be easier to post.
 
Thanks guys.
0 Kudos
Message 4 of 9
(3,675 Views)
I tried using find and it really is faster.  However, using it with systemexec causes windows problems for me.  Using it in a cli / prompt is fine.
 
It gives me this error and asks me the usual (if I want to send the error to Microsoft).  Anyone out there with ideas?

Find String (grep) Utility has encountered a problem and needs to close. We are sorry for the inconvenience

 

0 Kudos
Message 5 of 9
(3,670 Views)
Hello,
 
Can you attach your code, or a screenshot, so we can see exactly how your are using systemexec?
 
If you can, I can try to reproduce the problem, and perhaps find a solution!
 
Thank you,
 
Best Regards,
 
JLS
Best,
JLS
Sixclear
0 Kudos
Message 6 of 9
(3,654 Views)

Hi JLS,

Even a simple systemexec with a string such as find /i "56743" \\DataServer\ExcelFiles alone on vi produces this error.  In fact, even an erroneous use of the find(grep) command such as wiring only the find string to the systemexec command line generates the error.  I've tried putting the command in the batch file and tried it on several pc's.  It's doing the same thing so I am guessing that it might actually be a LabView bug.  I am using LabView 7.1 on a Windows XP computer.   The command works fine in a simple command line (not using LabView).  It also works by executing a batch file on Windows containing the command.  Use it in system exec, however, and it produces the error.

Attached are some screenshots of both the very simple block diagram and the error that gets generated.

 

Download All
0 Kudos
Message 7 of 9
(3,636 Views)

hi there

i can reproduce the error you described. when connection the "standard input" - control the system exec - call works fine (probably the find.exe reads stdin()). see attachment...

btw.: i've seen a function findstr.exe. this supports regular expressions. see windows online help for more.

 

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
Message 8 of 9
(3,628 Views)
This is awesome!  Thanks for the help, Chris.
 
I've found that the findstr command you  mentioned is a lot faster than the find command.  And although it seems like it reads excel files like text files, it works for what I need to do.  I just cut my test time threefold.  Thanks again.
 
Joseph
0 Kudos
Message 9 of 9
(3,619 Views)