# Mongodb and Julia : how to go from Vector of BSON documents to a dataframe

**URL:** <https://discourse.julialang.org/t/mongodb-and-julia-how-to-go-from-vector-of-bson-documents-to-a-dataframe/80465>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [May 4, 2022, 7:42am UTC](https://discourse.julialang.org/t/mongodb-and-julia-how-to-go-from-vector-of-bson-documents-to-a-dataframe/80465 "2022-05-04T07:42:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julia\_fun\_123](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@Julia\_fun\_123](https://discourse.julialang.org/u/Julia_fun_123)\
**Post date:** [May 4, 2022, 7:42am UTC](https://discourse.julialang.org/t/mongodb-and-julia-how-to-go-from-vector-of-bson-documents-to-a-dataframe/80465/1 "2022-05-04T07:42:07Z")

</div>

Hello.

I have been looking at the Mongoc.jl documentation on and off for several months, but I haven’t been able to find a way to convert BSON data to a DataFrame.

The data I am using is from the yelp dataset, found here : [https://raw.githubusercontent.com/melqkiades/yelp/master/notebooks/yelp\_academic\_dataset\_business.json](https://raw.githubusercontent.com/melqkiades/yelp/master/notebooks/yelp_academic_dataset_business.json)

This is the code that I have so far :

```julia

using DataFrames
using CSV
using Pipe
using Mongoc

client = Mongoc.Client()
database = client["local"]
collection = database["yelp"]
bson_options = Mongoc.BSON("""
{ "projection" : { "_id" : false, "city" : true, 
    "attributes.Noise Level" : true, 
    "attributes.Ambience.casual" : true}},
{"sort" : { "city" : 1, "attributes.Noise Level" : 1, "attributes.Ambience.casual" : 1} }

""")

mongo_data = Mongoc.find(collection,options=bson_options)

vector_bson_docs_mongo_data = collect(mongo_data)

```

I basically want to do the same as I would with PostgreSQL’s JSON manipulation capabilities :

```julia
using LibPQ
using DataFrames

conn = LibPQ.Connection("dbname=myusername")
df = DataFrame(execute(conn, """

SELECT
info ->> 'city' AS city,
info -> 'attributes' ->> 'Noise Level' AS noise_level,
info -> 'attributes' -> 'Ambience' ->> 'casual' AS casual
FROM yelpo
ORDER BY city ASC, noise_level ASC, casual ASC;
        

"""))

df

```

How would one go about converting all the mongodb data to a DataFrame ?
