Пример #1
0
def create_survey_from_xls(path_or_file):
    excel_reader = SurveyReader(path_or_file)
    d = excel_reader.to_json_dict()
    survey = create_survey_element_from_dict(d)
    if not survey.id_string:
        survey.id_string = excel_reader._name
    return survey
Пример #2
0
def create_survey_from_xls(path_or_file):
    excel_reader = SurveyReader(path_or_file)
    d = excel_reader.to_json_dict()
    survey = create_survey_element_from_dict(d)
    if not survey.id_string:
        survey.id_string = excel_reader._name
    return survey
Пример #3
0
def load_file_to_dict(path):
    if path.endswith(".xls") or path.endswith(".csv"):
        name = _section_name(path)
        excel_reader = SurveyReader(path)
        return (name, excel_reader.to_dict())
    elif path.endswith(".json"):
        name = _section_name(path)
        return (name, utils.get_pyobj_from_json(path))
Пример #4
0
def create_survey_from_xls(path):
    """
    Interestingly enough this behaves differently than a json dump and
    create survey element from json. This is because to questions that
    share the same choice list cannot share the same choice list in
    json. This is definitely something to think about.
    """
    excel_reader = SurveyReader(path)
    d = excel_reader.to_dict()
    return create_survey_element_from_dict(d)
Пример #5
0
def create_survey_from_xls(path):
    """
    Interestingly enough this behaves differently than a json dump and
    create survey element from json. This is because to questions that
    share the same choice list cannot share the same choice list in
    json. This is definitely something to think about.
    """
    excel_reader = SurveyReader(path)
    d = excel_reader.to_dict()
    return create_survey_element_from_dict(d)
Пример #6
0
def load_file_to_dict(path):
    """
    Takes a file path and loads it into a nested json dict following the format in json_form_schema.json
    The file may be a xls file or json file. If it is xls it is converted using xls2json.
    """
    if path.endswith(".json"):
        name = _section_name(path)
        return (name, utils.get_pyobj_from_json(path))
    else:
        name = _section_name(path)
        excel_reader = SurveyReader(path)
        return (name, excel_reader.to_json_dict())
Пример #7
0
def load_file_to_dict(path):
    """
    Takes a file path and loads it into a nested json dict following the format in json_form_schema.json
    The file may be a xls file or json file. If it is xls it is converted using xls2json.
    """
    if path.endswith(".xls") or path.endswith(".csv"):
        name = _section_name(path)
        excel_reader = SurveyReader(path)
        return (name, excel_reader.to_json_dict())
    elif path.endswith(".json"):
        name = _section_name(path)
        return (name, utils.get_pyobj_from_json(path))
Пример #8
0
def xls2json(name):
    converter = SurveyReader("%s.xls" % name)
    converter.print_json_to_file()
Пример #9
0
def create_survey_from_xls(path):
    excel_reader = SurveyReader(path)
    d = excel_reader.to_dict()
    return create_survey_element_from_dict(d)
Пример #10
0
def xls2json(name):
    converter = SurveyReader("%s.xls" % name)
    converter.print_json_to_file()