From dc1327674c2676db02ccf525725019cd9115b699 Mon Sep 17 00:00:00 2001 From: Wookey Date: Mon, 11 Jul 2011 02:10:22 +0100 Subject: remove all the DOS linefeeds --- export/toqms.py | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'export/toqms.py') diff --git a/export/toqms.py b/export/toqms.py index a6a264a..2564094 100644 --- a/export/toqms.py +++ b/export/toqms.py @@ -1,16 +1,16 @@ -import troggle.core.models as models -from django.conf import settings - -import csv -import re -import os - -#format of QM tables -headers=['Number','Grade','Area','Description','Page reference','Nearest station','Completion description','Comment'] - -def qmRow(qm): - #mapping of troggle models to table columns is: (guess this could just be a tuple of tuples rather than a dictionary actually) - columnsToModelFields={ +import troggle.core.models as models +from django.conf import settings + +import csv +import re +import os + +#format of QM tables +headers=['Number','Grade','Area','Description','Page reference','Nearest station','Completion description','Comment'] + +def qmRow(qm): + #mapping of troggle models to table columns is: (guess this could just be a tuple of tuples rather than a dictionary actually) + columnsToModelFields={ 'Number':str(qm.number), 'Grade':qm.grade, 'Area':qm.area, @@ -18,19 +18,19 @@ def qmRow(qm): #'Page reference': #not implemented 'Nearest station':qm.nearest_station_description, 'Completion description':qm.completion_description, - 'Comment':qm.comment - } - - qmRow=['' for x in range(len(headers))] - for column, modelField in columnsToModelFields.items(): - if modelField: - # Very sorry about the atrocious replace below. I will fix this soon if noone beats me to it. - AC - qmRow[headers.index(column)]=modelField.replace(u'\xd7','x').replace(u'\u201c','').replace(u'\u2013','').replace(u'\xbd','') - return qmRow - -def writeQmTable(outfile,cave): - cavewriter=csv.writer(outfile,lineterminator='\r') - cavewriter.writerow(headers) - for qm in cave.get_QMs(): - cavewriter.writerow(qmRow(qm)) + 'Comment':qm.comment + } + + qmRow=['' for x in range(len(headers))] + for column, modelField in columnsToModelFields.items(): + if modelField: + # Very sorry about the atrocious replace below. I will fix this soon if noone beats me to it. - AC + qmRow[headers.index(column)]=modelField.replace(u'\xd7','x').replace(u'\u201c','').replace(u'\u2013','').replace(u'\xbd','') + return qmRow + +def writeQmTable(outfile,cave): + cavewriter=csv.writer(outfile,lineterminator='\r') + cavewriter.writerow(headers) + for qm in cave.get_QMs(): + cavewriter.writerow(qmRow(qm)) \ No newline at end of file -- cgit v1.2.3