Friday, August 30, 2013

Python get path

The task is to rip the directory part from a full path file name. Split is handy, but not helpful since doing something like splitting on '/' would just get any number of separate pieces, using the number of pieces argument isn't helpful because the directory could have any number of pieces. Python has a function called rsplit, problem solved except that for some reason it's not in my ridiculously old revision of Python (2.3).

There is a whole library that does this called ntpath. Tried it, it's great. It also seems to autonomously convert Windows paths to *nux paths. Here's the link:

http://stackoverflow.com/questions/8384737/python-extract-file-name-from-path-no-matter-what-the-os-path-format

But it turns out that os.path.split would work just as well, plus os.path does all kinds of other great stuff too:

http://docs.python.org/2/library/os.path.html

I also learned that in my version of Python, and probably in all later versions, it is possible to use regular split with negative numbers to transverse the split array from the right, thusly:

filename=fullpath.split('/')[-1]

In order to take a full path file name and get the lowest directory level from the path, the easiest trick seems to be to use os.path.dirname and then use split with -1:

path=os.path.dirname(fullpath)
bottom_dir = path.split('/')[-1]


excel 2013 copy worksheets between workbooks

Turns out it couldn't be easier. Just have both workbooks open. Then the "Move or Copy" dialog has an option for selecting which workbook you will be copying to!

Here's a link:

http://www.dummies.com/how-to/content/how-to-move-a-worksheet-to-another-excel-2013-work.html

Windows 7 Remote Desktop with Dual Monitor

Works great! It seems that a key to getting it to work is to have both monitors on the local system set to identical resolution.

Here is a very nice write-up. This blog, like others, seemed to hint that this will only work if both system are "Ultimate" or "Enterprise", however, it worked well for me and my remote system was "Professional"

http://www.techrepublic.com/blog/windows-and-office/use-multiple-monitors-with-windows-7s-remote-desktop-connection/

One key not mentioned in the above link is to run the remote desktop app in /span mode, which seems to mean starting it in a cmd window with this command:

mstsc /span

This link goes into setting up the two monitors to be identical in size:

http://www.splitview.com/using-remote-desktop-with-dual-monitors-in-span-mode

Here's the same info from M$:

http://answers.microsoft.com/en-us/windows/forum/windows_7-networking/windows-7-remote-desktop-with-multi-monitor/6bf0d5e3-644f-404e-baaf-ff2085e1c2c2