Skip to content

Instantly share code, notes, and snippets.

@jermnelson
Created April 17, 2013 17:55
Show Gist options
  • Save jermnelson/5406363 to your computer and use it in GitHub Desktop.
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
"""
"""
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()
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