List files ONLY in the current directory

Just use os.listdir and os.path.isfile instead of os.walk. Example: But be careful while applying this to other directory, like which would not work because f is not a full path but relative to the current dir. Therefore, for filtering on another directory, do os.path.isfile(os.path.join(somedir, f)) (Thanks Causality for the hint)

Git: How do I force “git pull” to overwrite local files?

⚠ Important: If you have any local changes, they will be lost. With or without –hard option, any local commits that haven’t been pushed will be lost.[*] If you have any files that are not tracked by Git (e.g. uploaded user content), these files will not be affected. First, run a fetch to update all origin/<branch> refs to latest: Backup your … Read more

duplicate ‘row.names’ are not allowed error

Then tell read.table not to use row.names: and now your rows will simply be numbered. Also look at read.csv which is a wrapper for read.table which already sets the sep=’,’ and header=TRUE arguments so that your call simplifies to

Categories R

Short circuit Array.forEach like calling break

There’s no built-in ability to break in forEach. To interrupt execution you would have to throw an exception of some sort. eg.  Run code snippetExpand snippet JavaScript exceptions aren’t terribly pretty. A traditional for loop might be more appropriate if you really need to break inside it. Use Array#some Instead, use Array#some:  Run code snippetExpand snippet This works because some returns true as soon as any of the … Read more