开发者

How to grep this and NOT that?

I am trying to return a file name from list.files, but there are 2 similarly named files. filename.csv filename_review.csv

I want to put each file name into its own list. Doing that for filename_review.csv is easy since it has unique stuff in it, but how do I sift out the other? I need to grep(".csv", list.files()) wi开发者_如何学Pythonthout getting filename_review.csv returned.


Showing all files in the working directory that has a csv extension but not ends in review could be done:

setdiff(list.files(pattern='.csv$'), list.files(pattern='review.csv$'))


Another option is to grep for what you don't want, and then return everything else.

csvs <- list.files(patt='.csv$')
csvs[!grepl('_', csvs)


Found this... fileListBig[!(fileListBig %in% fileListSmall)] and that works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜