Python list directory, subdirectory, and files

Use os.path.join to concatenate the directory and file name: Note the usage of path and not root in the concatenation, since using root would be incorrect. In Python 3.4, the pathlib module was added for easier path manipulations. So the equivalent to os.path.join would be: The advantage of pathlib is that you can use a variety of useful methods on paths. If you use the concrete Path variant you can also do actual OS … Read more

fatal: Not a valid object name: ‘master’

When I git init a folder it doesn’t create a master branch This is true, and expected behaviour. Git will not create a master branch until you commit something. When I do git –bare init it creates the files. A non-bare git init will also create the same files, in a hidden .git directory in the root of your project. When I type git branch master it … Read more

Regex for string contains?

Assuming regular PCRE-style regex flavors: If you want to check for it as a single, full word, it’s \bTest\b, with appropriate flags for case insensitivity if desired and delimiters for your programming language. \b represents a “word boundary”, that is, a point between characters where a word can be considered to start or end. For example, since spaces are … Read more

Find duplicate values in R

You could use table, i.e. gives you a data frame with a list of ids and the number of times they occurred. tells you which ids occurred more than once. returns the records with more than one occurrence.

Categories r