This function appends a Study object to an ISA file
    Typically, you should use the exploreISA function to check the contents
    of the ISA file!
    :param study: The Study object.
    :type study: ISA Study object
    :param pathToISATABFile: The path to the ISATAB file
    :type pathToISATABFile: string
    :raise FileNotFoundError: If pathToISATABFile does not contain file 'i_Investigation.txt'.

def appendStudytoISA(study, pathToISATABFile):
    """
    This function appends a Study object to an ISA file
    Typically, you should use the exploreISA function to check the contents
    of the ISA file!
    :param study: The Study object.
    :type study: ISA Study object
    :param pathToISATABFile: The path to the ISATAB file
    :type pathToISATABFile: string
    :raise FileNotFoundError: If pathToISATABFile does not contain file 'i_Investigation.txt'.
    """
    from isatools import isatab
    import os
    try:
        isa = isatab.load(pathToISATABFile, skip_load_tables=True)
        lngth = len(isa.studies)
        base = os.path.basename(study.filename)
        fname = os.path.splitext(base)[0]
        fname = fname + str(lngth)
        ext = os.path.splitext(base)[1]
        fname = fname + ext
        study.filename = fname
        isa.studies.append(study)
        isatab.dump(isa_obj=isa, output_path=pathToISATABFile)
    except FileNotFoundError as err:
        raise err