Question: I want to create a list of all the ***filepath names*** that match a specific string e.g. "04\_DEM" so I can do further processing on the files inside those directories?

e.g. 

INPUT

```
 C:\directory\NewZealand\04DEM\DEM_CD23_1232.tif
 C:\directory\Australia\04DEM\DEM_CD23_1233.tif
 C:\directory\NewZealand\05DSM\DSM_CD23_1232.tif
 C:\directory\Australia\05DSM\DSM_CD23_1232.tif

```

WANTED OUTPUT

```
 C:\directory\NewZealand\04DEM\
 C:\directory\Australia\04DEM\

```

This makes sure that only those files are processed, as some other files in the directories also have the same string "DEM" included in their filename, which I do not want to modify.

This is my bad attempt due to being a rookie with Py code 

```
 import os

 for dirnames in os.walk('D:\Canterbury_2017Copy'):
     print dirnames
     if dirnames=='04_DEM' > listofdirectoriestoprocess.txt

 print "DONE CHECK TEXT FILE"

```

Answer: 
Since it seems as though the problem is that you have saved your numeric data as characters in Excel (instead of using format to display the commas) you may want a function like this.

```
#' Replace Commas Function
#'
#' This function converts a character representation of a number that contains a comma separator with a numeric value.
#' @keywords read data
#' @export
replaceCommas<-function(x){
  x<-as.numeric(gsub("\\,", "", x))
}

```

Then

```
rcffull$RetBackers <- replaceCommas(rcffull$Returning.Backers)
rcffull$NewBackers <- replaceCommas(rcffull$New.Backers)

```
The reason that G5W is asking for `dput` ouput is that he (we) are unable to figure out where something that displays as `8180` when it's a factor might not properly be converted with that code. It's not because of leading or trailing spaces (which would not appear in a `print`-version of a factor. Witness this test:

```
>  as.numeric(as.character(factor(" 8180")))
[1] 8180
> as.numeric(as.character(factor(" 8180 ")))
[1] 8180

```

And the fact that it gets converted to 0 is a real puzzle since generally items that do not get recognized as parseable R numerics will get coerced to NA (with a warning).

```
> as.numeric(as.character(factor(" 0 8180 ")))
[1] NA
Warning message:
NAs introduced by coercion 

```

We really need the `dput` output from the item that displays as "8180" and its neighbors.