Exporting data to Firebase

Asked

Viewed 39 times

0

I’m trying to export a Python database to Firebase. My database is a JSON in the following format:

'{
   "0":{
         "country":"Italy",
         "description":"Aromas include tropical fruit, broom, brimstone and dried herb. The palate isn\'t overly expressive, offering unripened apple, citrus and dried sage alongside brisk acidity.",
         "designation":"Vulk\\u00e0 Bianco",
         "points":87,
         "price":null,
         "province":"Sicily & Sardinia",
         "region_1":"Etna",
         "region_2":null,
         "taster_name":"Kerin O\\u2019Keefe",
         "taster_twitter_handle":"@kerinokeefe",
         "title":"Nicosia 2013 Vulk\\u00e0 Bianco  (Etna)",
         "variety":"White Blend",
         "winery":"Nicosia"},

I am creating nodes as timestamp, and trying to import only the first 1000 JSON values into nodes using the following function:

i = 0

for key, wine in df.items():
    if i < 1000:
        id = int(time())
        db.child("wines").child(id).push(wine.val())
        i += 1
    else:
        break

But I’m getting the following error:

Attributeerror: 'Series' Object has no attribute 'val'

Does anyone know the correct way to call only the dictionary values?

  • Shouldn’t you push Wine? I think for key, wine (...) you will have the key in key and the object of the wine.

  • I did as you commented and returned the following error: Typeerror: Object of type Series is not JSON serializable

  • Have you tried that: db.child("wines").child(id).push(json.dumps(wine))? You have to import the lib json first: import json

  • 1

    Guys, I managed to solve, I turned my information into a Pandas Dataframe and applied the following code: id = int(time()+i Wine = df.iloc[i] Wine = Wine.to_json() db.Child("Wines"). Child(id). push(Wine)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.