Small Python Firebase Upload Script
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

I need a small Python script which will:

  1. Fetch all XML files from a target FTP location
  2. Loop through each file and upload all nodes that have values as key/value pairs to Wilddog (same thing as Firebase and use same codebase)
  3. Have a parameter for upload path like this:

So if a sample XML file look like this:

<?xml version="1.0" encoding="GB2312"?>
<PortMessageXML File_Type="BRR">
        <FailReason />
        <CreateTime>2016-09-09 08:17:57</CreateTime>

Then the uploaded data should look like this: {
    variable_xml_node_value_1: {
        variable_xml_node_value_2: {
            some_other_fixed_name: {
                BRR20160909081758110-80546984_74655: {
                    VoyageNO: 110-80546984,
                    BillNO: 20160906110034256670,
                    CheckNO: 110000K11699I9O,
                    Result: 1,
                    Receiver: bjkj0015,
                    CreateTime: 2016-09-09 08:17:57,
                    file_name: BRR20160909081758110-80546984_74655

“BRR20160909081758110-80546984_74655” is the file name, so this part should be each file’s file name.

In the uploaded data I need an extra node called “file_name” which includes the actual file name.

The “variable_xml_node_value_1” and “variable_xml_node_value_2” should be XML node names but using their actual values.

For example an actual parameter would look like:

And the actual uploaded data is like:

some_fixed_name: {
    20160906110034256670: {
        110000K11699I9O: {
            some_other_fixed_name: {
                same as above

Below is a download link to a small Python script I have that does something similar, you can modify it for the new script if necessary

is the input file format fixed i.e. do the key/value pairs always appear at the second level from the root node?
asr almost 3 years ago
awarded to iurisilvio

Crowdsource coding tasks.

2 Solutions

Winning solution

I sent you the answer in private.

View Timeline