Changeset 33224


Ignore:
Timestamp:
2019-06-26T16:48:48+12:00 (5 years ago)
Author:
davidb
Message:

Further code tidy-up

Location:
main/trunk/model-sites-dev/heritage-nz/collect/pdf-reports/prepare
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-sites-dev/heritage-nz/collect/pdf-reports/prepare/xls-to-csv.py

    r33222 r33224  
    143143                    header_name = u"TLA"
    144144
    145 #                header_name_utf8 = unicode(header_name).encode("utf-8")
    146145                header_name_utf8 = header_name.encode("utf-8")
    147146                metadata_name_utf8 = header_name_utf8.replace(" ", "")
     
    184183                        # Check to see if companion PDF file present
    185184                        # pdf_filename = os.path.join(excel_dirname,"pdfs",formatted_cell_value+".pdf")
    186                         id = formatted_cell_value.replace(" ","")
     185                        id = formatted_cell_value.replace(" ","-")
    187186                       
    188187                        pdf_file = id_to_relative_pdf_file(id)
     
    202201                            print "Unbound id: '" + id + "'"
    203202
    204                     if isinstance(formatted_cell_value, basestring):
    205                         # Remove any trailing whitespace. 
    206                         # Newline at end particular harmful for a entry in the CSV file
    207                         formatted_cell_value = formatted_cell_value.rstrip();
    208 
    209 #                    formatted_cell_value_utf8 = unicode(formatted_cell_value).encode("utf-8")
     203#                    if isinstance(formatted_cell_value, basestring):
     204#                        # Remove any trailing whitespace. 
     205#                        # Newline at end particular harmful for a entry in the CSV file
     206#                        formatted_cell_value = formatted_cell_value.rstrip();
     207
    210208                    formatted_cell_value_utf8 = formatted_cell_value.encode("utf-8")
    211209
  • main/trunk/model-sites-dev/heritage-nz/collect/pdf-reports/prepare/xls-to-sanitized-csv.py

    r33222 r33224  
    1111    worksheet = workbook.sheet_by_index(xlsutil.worksheet_index_pos)
    1212    ## worksheet = workbook.sheet_by_name(xlsutil.worksheet_name)
    13 
    14     # excel_filename_split = os.path.split(excel_filename)
    15     # excel_dirname = excel_filename_split[0]
    16     # excel_file = excel_filename_split[1]
    17     # excel_file_splitext = os.path.splitext(excel_file)
    18     # excel_file_root = excel_file_splitext[0];
    19 
    20     # sanitized_csv_filename  = os.path.join("for-download",excel_file_root+".csv")
    2113
    2214    sanitized_csv_ofile = open(sanitized_csv_filename, 'wb')
     
    4941                header_col_j = header_names_mapping[header_name]
    5042
    51 #                cell_value = worksheet.cell_value(row_i,header_col_j)
    52 #
    53 #                cell_value_utf8 = unicode(cell_value).encode("utf-8")
    54 
    5543                cell_value_unicode = xlsutil.cell_value_tidy_unicode(worksheet,row_i,header_col_j)
    56 
    5744                cell_value_utf8 = cell_value_unicode.encode("utf-8")
    58 
    59 ##                cell_value_utf8 = unicode(cell_value).encode("utf-8")
    6045
    6146                sanitized_utf8_row.append(cell_value_utf8)
Note: See TracChangeset for help on using the changeset viewer.