--- /dev/null
+This script makes the following assumptions (and doesn't check if these reqs are not met):
+
+*library system names don't have parens AND the word 'row' in their name
+*the first column of every line identifies what file we want to write THIS line to
+*if that item has a '-' in it, remove the contents after and including the '-'
+*there exists an 'output' directory within the current directory
+*there exists a 'csv' directory within the current directory that contains all of the .csv files you want to process
+*All of said csv files contain a line at the top containing the column headers
+*that the scripts will be run from the current directory
+*that file system is in the right state for us to write to (permissions, space, actually exists etc)
+
+you can run the python script on an individual file:
+
+#INSERT EXAMPLE
+
+or you can just run ./do_all.sh to iterate over all files in the csv folder
--- /dev/null
+#!/usr/bin/python
+
+import os
+import sys
+
+if len(sys.argv) != 2:
+ print "Usage: <scriptname> csv/blah.csv"
+ quit()
+fname = sys.argv[1].split('/')[1]
+report_name = fname.split('.csv')[0]
+
+f = open ('csv/'+fname,'r')
+header = f.readline()
+lines = f.readlines()
+output=dict()
+for line in lines:
+ #check for just systems e.g. STATELIB instead of the expected STATELIB-L
+ tmp = line.split(',')[0]
+ if tmp.find('-') == -1:
+ libsys = tmp
+ else:
+ libsys = line.split('-')[0]
+ #remove any whitespace junk that may have made it thus far:
+ libsys = libsys.strip()
+
+ #if there are any lines that don't look right or lack a lib name, notify us, and discard the line by
+ #continuing on to the next item in the for loop
+ if libsys == "":
+ print "Couldn't identify library for this line:", line
+ print "This was contained in:", fname
+ continue
+ #attempt to detect row count lines and skip to the next item if we think we got one
+ #probably could have regex matched it
+ if libsys.find('(') != -1 or libsys.find(')') != -1:
+ if libsys.find('row') != -1:
+ print "We most linkely encountered a row count line:"+line+" in file:"+fname
+ continue
+
+
+ #check to make sure we don't try to append to a non-existant object, and then add to the list object
+ if libsys not in output:
+ output[libsys]=list()
+ output[libsys].append(line)
+
+#iterate through the dictionary we just created, and generate the files
+for k,v in output.items():
+ outfile = open('output/'+k+'-'+fname,'w')
+ outfile.write(header)
+ for line in v:
+ outfile.write(line)
+ outfile.close()
+
+
+f.close()