SearchFiles: Search files

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/utils.R

Description

Search files according to the pattern.

Usage

1
searchFiles(pattern, content = FALSE, Fid = NULL, Widget = NULL,is.UTF8 = FALSE)

Arguments

pattern

The criterion of search, see examples section for examples.

content

When it is TRUE, the content of files fitting the pattern will be returned as well.

Fid

integer vector, the ids of subset of files to search.

Widget

Character, name of a gtable widget. If it is not NULL, the file names fitting the pattern will pushed to that gtable widget using svalue method. One useful value is ".fnames_rqda", so the file names will be pushed to the Files Tab of RQDA. Others are ".FileofCat" and ".FileofCase".

is.UTF8

If the coding of pattern is UTF-8. If you are not sure, always use FALSE.

Details

This function uses select statement of sql to search files (from source database table). The pattern is the WHERE clause (without the keyword WHERE). For more information, please refer to the website of SQLite syntax. All data in *.rqda use UTF-8 encoding, so the encoding of pattern matters. It will be converted to UTF-8 if it is not (is.UTF8=FALSE).

Value

A data frame with variables (which is invisible and you need to print it explicitly):

id

The file id.

name

The file name.

file

The file content. Only return when content is TRUE.

Author(s)

HUANG Ronggui

References

http://www.sqlite.org/lang_expr.html

See Also

gtable, localeToCharset

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 
searchFiles("file like '%keyword%'") 
## search for files who contain the word of "keyword"
searchFiles("file like 'keyword%'") 
## search for files whose content begin with the word of "keyword"
searchFiles("name like '%keyword'") 
## search for files whose name end with the word of "keyword"
searchFiles("name like '%keyword one' and file like '%keyword tow%'") 
## combined conditions

## End(Not run)

Ronggui/RQDA documentation built on Nov. 22, 2021, 12:21 a.m.