Changeset 33192 for main

Show
Ignore:
Timestamp:
22.06.2019 10:44:47 (3 months ago)
Author:
davidb
Message:

More carefully control where the sanitized CSV file is generated

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

Legend:

Unmodified
Added
Removed
  • main/trunk/model-sites-dev/heritage-nz/collect/pdf-reports/PREPARE-IMPORT.sh

    r33188 r33192  
    55 
    66echo "Generating sanitized CSV version of spreadsheet suitable for download through DL" 
    7 python prepare/xls-to-sanitized-csv.py "import/Archaeological report PDFs 20190620.xlsx" 
     7python prepare/xls-to-sanitized-csv.py \ 
     8  "import/Archaeological report PDFs 20190620.xlsx" \ 
     9  "for-download/Archaeological-Reports-20190620.xlsx" 
    810 
    911echo "Generating PDF-Bound and Unbound CSV files for use in import.pl" 
  • main/trunk/model-sites-dev/heritage-nz/collect/pdf-reports/prepare/xls-to-sanitized-csv.py

    r33191 r33192  
    22import csv 
    33import os 
     4import sys 
    45 
    56import xlsutil 
    67 
    7 def excel_to_sanitized_csv(excel_filename): 
     8def excel_to_sanitized_csv(excel_filename,sanitized_csv_filename): 
    89    workbook = xlrd.open_workbook(excel_filename) 
    910 
     
    1112    ## worksheet = workbook.sheet_by_name(xlsutil.worksheet_name) 
    1213 
    13     excel_filename_split = os.path.split(excel_filename) 
    14     excel_dirname = excel_filename_split[0] 
    15     excel_file = excel_filename_split[1] 
    16     excel_file_splitext = os.path.splitext(excel_file) 
    17     excel_file_root = excel_file_splitext[0]; 
     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]; 
    1819 
    19     sanitized_csv_filename  = os.path.join(excel_dirname,excel_file_root+".csv") 
     20    # sanitized_csv_filename  = os.path.join("for-download",excel_file_root+".csv") 
    2021 
    2122    sanitized_csv_ofile = open(sanitized_csv_filename, 'wb') 
     
    6364 
    6465if __name__ == "__main__": 
    65     excel_to_sanitized_csv(os.sys.argv[1]) 
     66    if len(os.sys.argv) != 3: 
     67        print >> sys.stderr, "Usage: " + os.sys.argv[0] + "input.xsl|input.xslx output.csv" 
     68        exit(1) 
    6669 
     70    excel_to_sanitized_csv(os.sys.argv[1],os.sys.argv[2]) 
     71