Exemple #1
0
def xml_to_dataframe():
    args = parse_commandline_arguments()

    if args.xml and args.dict_file:
        xml_file = args.xml
        output_dict = args.dict_file
        wetten_dict = wetten_xml_to_dict.parse_xml_artikelen(
            xml_file, output_dict)
        if args.df_file:
            output_df = args.df_file
            xml_df = dict_to_dataframe.dict_to_dataframe(
                wetten_dict, output_df)
        else:
            print(f'finished with parsing xml to dictionary, check file: ' +
                  output_dict)

    elif args.dict_file and args.df_file and not args.xml:
        input_dict_file = args.dict_file
        output_df_file = args.df_file
        dict_to_dataframe.dict_to_dataframe(input_dict_file, output_df_file)
        print(
            f'finished with creating dataframe from dictionary, check file: ' +
            output_df_file)

    else:
        print(
            'you did not pass the right combination of arguments, parsing not possible.'
        )
def test_dict_to_dataframe_regeling_regression():
    my_dict = json_to_dict("test_data/BWBR0043324_2020-04-22_0_TOGS.json")
    with tempfile.NamedTemporaryFile() as result:
        expected_path = "test_data/expected_regression_regeling.csv"
        result_path = result.name + ".csv"
        dict_to_dataframe(my_dict, result_path)
        assert [row for row in open(result_path)] == [row for row in open(expected_path)]
def test_dict_to_dataframe_lerarenbeurs_regression():
    my_dict = json_to_dict("test_data/BWBR0039319_2020-06-24_0_lerarenbeurs.json")
    with tempfile.NamedTemporaryFile() as result:
        expected_path = "test_data/expected_regression_lerarenbeurs.csv"
        result_path = result.name + ".csv"
        dict_to_dataframe(my_dict, result_path)
        assert [row for row in open(result_path)] == [row for row in open(expected_path)]
def test_dict_to_dataframe_wetbesluit_regression():
    my_dict = json_to_dict("test_data/BWBR0011823_2019-02-27_Vreemdelingenwet.json")
    with tempfile.NamedTemporaryFile() as result:
        expected_path = "test_data/expected_regression_wetbesluit.csv"
        result_path = result.name + ".csv"
        dict_to_dataframe(my_dict, result_path)
        assert [row for row in open(result_path)] == [row for row in open(expected_path)]
def update_expected_regression_wetbesluit():
    my_dict = json_to_dict("test_data/BWBR0011823_2019-02-27_Vreemdelingenwet.json")
    expected_path = "test_data/expected_regression_wetbesluit.csv"
    dict_to_dataframe(my_dict, expected_path)
def update_expected_regression_regeling():
    my_dict = json_to_dict("test_data/BWBR0043324_2020-04-22_0_TOGS.json")
    expected_path = "test_data/expected_regression_regeling.csv"
    dict_to_dataframe(my_dict, expected_path)