#! /usr/bin/env python
# -*- coding: utf-8 -*-

"""Turn Excel metadata from SMVK into JSON-file for further processing.

Input: Excel-file
Processing: strip whitespace etc
Output: JSON-file `cypern_metadata.json" containg dict in the current directory
"""
import pandas as pd
import argparse

def main():
    """Illustrate function-level docstring.
    
    Note that all docstrings begin with a one-line summary. The summary is
    written in the imperative mood ("do", "use", "find", "return", "render",
    etc) and ends with a period. The method signature is not, in any way,
    duplicated into the comments (that would be difficult to maintain).
    All subsequent paragraphs in a docstring are indented exactly the same as
    the summary line. The same applies to the closing quotation marks.
    
    """
    try:
        metadata = pd.read_excel(args.infile)
    except IOError as e:
        print("IOError: {}".format(e))

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument("--infile",default="../excel-export.xls")
    parser.add_argument("--fname-file",default="SMVK-Cypern_2017-01_filename_mappings.csv")
    parser.add_argument("-outfile", default="SMVK-Cypern_2017-01_metadata.json")
    args = parser.parse_args()
    main()
@@ -290,525 +290,642 @@
 se%0A%0A
+%0A
 def 
-main():%0A    %22%22%22Illustrate function-level docstring.
+strip(text):%0A    try:
 %0A    
-%0A
     
-Note that all docstrings begin with a one-line summary. The summary is%0A    written in the imperative mood (%22do%22, %22use%22, %22find%22, %22return%22, %22render%22,%0A    etc) and ends with a period. The method signature is not, in any way,%0A    duplicated into the comments (that would be difficult to maintain).%0A    All subsequent paragraphs in a docstring are indented exactly the same as%0A    the summary line. The same applies to the closing quotation marks.%0A    %0A    
+return text.strip()%0A    except AttributeError:%0A        return text%0A%0A%0Acypern_converters = %7B%22Fotonummer%22: strip, %22Postnr%22: strip, %22Nyckelord%22: strip, %22Beskrivning%22: strip, %22Land%22: strip,%0A                     %22foto%22: strip,%0A                     %22Region, foto%22: strip, %22Ort, foto%22: strip, %22Geograf namn, alternativ%22: strip, %22Fotodatum%22: strip,%0A                     %22Personnamn / fotograf%22: strip, %22Personnamn / avbildad%22: strip, %22S%C3%B6kord%22: strip,%0A                     %22H%C3%A4ndelse / var n%C3%A4rvarande vid%22: strip, %22L%C3%A4nk%22: strip%7D%0A%0A%0Adef main():%0A    %22%22%22Read infile and output json-file and filenames mapping file.
 %22%22%22%0A
@@ -977,16 +977,66 @@
 s.infile
+, sheetname=%22Cypern%22, converters=cypern_converters
 )%0A    ex
@@ -1094,16 +1094,45 @@
 at(e))%0A%0A
+    print(metadata.info())%0A%0A%0A
 if __nam

Read sheetname 'Cypern' and strip column names