Created
June 25, 2013 03:18
-
-
Save AndrewPa/5855669 to your computer and use it in GitHub Desktop.
A little test function called "File Hoover". It's a recursive function that pulls the names of single files out of arbitrarily-nested subdirectories. I'm sure it's already been made thousands of times, but it was good practice. It's also my first "real" Python code! I threw in some basic FTP functions; I'm going to use a similar function to retr…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python | |
## Filename retriever: | |
import os | |
def hoover(): | |
for subdir in os.listdir('.'): | |
try: | |
os.chdir(str(subdir)) | |
except: | |
print(str(subdir)) | |
continue | |
hoover() | |
os.chdir('..') | |
hoover() | |
## FTP Functions: | |
#!/bin/python | |
import ftplib | |
ftp = ftplib.FTP('ftp.mrc-lmb.cam.ac.uk') | |
ftp.login() | |
ftp.cwd('/pub/tjucikas/wormdatabase/results-12-06-08/Laura Grundy') ## using this dir as a sort of "root" for our data | |
print ftp.pwd() ## ensure connection/directory change was successful |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment