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()
import pandas as pd
import argparse


def strip(text):
    try:
        return text.strip()
    except AttributeError:
        return text


cypern_converters = {"Fotonummer": strip, "Postnr": strip, "Nyckelord": strip, "Beskrivning": strip, "Land": strip,
                     "foto": strip,
                     "Region, foto": strip, "Ort, foto": strip, "Geograf namn, alternativ": strip, "Fotodatum": strip,
                     "Personnamn / fotograf": strip, "Personnamn / avbildad": strip, "Sökord": strip,
                     "Händelse / var närvarande vid": strip, "Länk": strip}


def main():
    """Read infile and output json-file and filenames mapping file."""
    try:
        metadata = pd.read_excel(args.infile, sheetname="Cypern", converters=cypern_converters)
    except IOError as e:
        print("IOError: {}".format(e))

    print(metadata.info())


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()
Read sheetname 'Cypern' and strip column names
Read sheetname 'Cypern' and strip column names

  import pandas as pd
  import argparse
  
+ 
+ def strip(text):
+     try:
+         return text.strip()
+     except AttributeError:
+         return text
+ 
+ 
+ cypern_converters = {"Fotonummer": strip, "Postnr": strip, "Nyckelord": strip, "Beskrivning": strip, "Land": strip,
+                      "foto": strip,
+                      "Region, foto": strip, "Ort, foto": strip, "Geograf namn, alternativ": strip, "Fotodatum": strip,
+                      "Personnamn / fotograf": strip, "Personnamn / avbildad": strip, "Sökord": strip,
+                      "Händelse / var närvarande vid": strip, "Länk": strip}
+ 
+ 
  def main():
+     """Read infile and output json-file and filenames mapping file."""
-     """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)
+         metadata = pd.read_excel(args.infile, sheetname="Cypern", converters=cypern_converters)
      except IOError as e:
          print("IOError: {}".format(e))
+ 
+     print(metadata.info())
+ 
  
  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()
Read sheetname 'Cypern' and strip column names
## Code Before:
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()
## Instruction:
Read sheetname 'Cypern' and strip column names
## Code After:
import pandas as pd
import argparse


def strip(text):
    try:
        return text.strip()
    except AttributeError:
        return text


cypern_converters = {"Fotonummer": strip, "Postnr": strip, "Nyckelord": strip, "Beskrivning": strip, "Land": strip,
                     "foto": strip,
                     "Region, foto": strip, "Ort, foto": strip, "Geograf namn, alternativ": strip, "Fotodatum": strip,
                     "Personnamn / fotograf": strip, "Personnamn / avbildad": strip, "Sökord": strip,
                     "Händelse / var närvarande vid": strip, "Länk": strip}


def main():
    """Read infile and output json-file and filenames mapping file."""
    try:
        metadata = pd.read_excel(args.infile, sheetname="Cypern", converters=cypern_converters)
    except IOError as e:
        print("IOError: {}".format(e))

    print(metadata.info())


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()