1. Rufus Pollock
  2. wdmmgext

Commits

AnnaPS  committed ca08bf1

[wdmmg][xs] really don't need that print statement

  • Participants
  • Parent commits 5c4f460
  • Branches default

Comments (0)

Files changed (1)

File wdmmgext/load/departments.py

View file
  • Ignore whitespace
 import util
 import wdmmg.model as model
 
-dataset_name = u'ukgov_departments'
+dataset_name = u'departments'
 dataset_long_name = u'UK central government department spending over 25,000' 
 dataset_currency = u'gbp'
 dataset_notes = u'UK central government department spending over 25,000'
     # Open the CSV workbook
     items = []
     reader = csv.reader(open(filepath, "rU"))
-    # try:
-    #     for row in reader:
-    #         print 'Row read with success!', row
-    # except csv.Error, e:
-    #     sys.exit('file %s, line %d: %s' % (filename, reader.line_num, e))
-    header = reader.next()
-    # Find the headers, stripping off any extra blank rows at start.
+    try:
+        header = reader.next()
+    except csv.Error, e:
+        reader = csv.reader(open(filepath, "rU"), dialect='excel')
+        header = reader.next()
+    print header
     while not [word for word in header if 'amount' in word.lower()]:
         header = reader.next()
     header = [h.lower().strip() for h in header]
              key_to: supplier.code,
              key_time: date, 
          }
-         print 'making transaction'
+         #print 'making transaction'
          for key, code in items.items():
              model.Session.add(model.ClassificationItem(
                  entry=txn,
     path = os.path.join(config['getdata_cache'], 'departments')
     for spending_file in glob.glob(os.path.join(path, '*.csv') ):
         print "Looking at file %s" % spending_file
-        #spending_file = 'Spend-Transactions-WO-06-Jun-2010.csv'
+        spending_file = 'Spend-Transactions-SO-OAG-06-Jun-2010.csv'
         department, subunit = get_department(spending_file)
         filepath = os.path.join(path, spending_file)
         if not ('BIS-UKTI-A-' in spending_file): # Weird formatting.
-             if not ('SO-OAG-' in spending_file): # 'NULL byte' errors - broken file?
-                load_file(unicode(filepath), unicode(department), unicode(subunit), \
+             #if not ('SO-OAG-' in spending_file): # 'NULL byte' errors - broken file?
+             load_file(unicode(filepath), unicode(department), unicode(subunit), \
                  commit_every=1000)
     model.Session.commit()
     model.Session.remove()