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:
    1. http://mysite.wilddogio.com/some_fixed_name/“variable_xml_node_value_1”/“variable_xml_node_value_2”/some_other_fixed_name

So if a sample XML file look like this:

<?xml version="1.0" encoding="GB2312"?>
<PortMessageXML File_Type="BRR">
    <BRR>
        <VoyageNO>110-80546984</VoyageNO>
        <BillNO>20160906110034256670</BillNO>
        <CheckNO>110000K11699I9O</CheckNO>
        <Result>1</Result>
        <Receiver>bjkj0015</Receiver>
        <FailReason />
        <CreateTime>2016-09-09 08:17:57</CreateTime>
    </BRR>
</PortMessageXML>

Then the uploaded data should look like this:

http://mysite.wilddogio.com/some_fixed_name: {
    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:
http://mysite.wilddogio.com/some_fixed_name/BillNO/CheckNO/some_other_fixed_name

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

http://expirebox.com/download/d3f53800f277eb253b63543c29ebe57b.html

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

Crowdsource coding tasks.

2 Solutions

Winning solution

I sent you the answer in private.

View Timeline