Created
April 17, 2013 17:55
-
-
Save jermnelson/5406363 to your computer and use it in GitHub Desktop.
Short python script for Wooster big data audit question for Oberlin Group list-server
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
""" | |
""" | |
import csv | |
import os | |
import argparse | |
parser = argparse.ArgumentParser(description='Takes a csv file and checks to see if file exists') | |
parser.add_argument('input_csv', help='Filename and path to the input csv file') | |
parser.add_argument('error_text', help='Name of text file that contains a listing of non-existant files') | |
args = parser.parse_args() | |
input_csv = csv.reader(open(args.input_csv, 'rb')) | |
error_text = open(args.error_csv, 'wb') | |
for row in input_csv: | |
filenames = row[0].split("|") | |
directory = row[1] | |
for name in filenames: | |
fullpath = os.path.join(directory, name) | |
if os.path.exists(fullpath) is False: | |
error_csv.write(fullpath) | |
error_text.close() | |
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
file1.pdf|file2.pdf|file3.pdf,C:\Users\jernelson\Development\tmp | |
file4.pdf|file5.pdf|file6.pdf,C:\Users\jernelson\Development\tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment