Exemplo n.º 1
0
def insert_autos(infile, db):
    autos = process_file(infile)

    # Your code here. Insert the data in one command
    # autos will be a list of dictionaries, as in the example in the previous video
    # You have to insert data in a collection 'autos'
    [db.autos.insert(e) for e in autos]
Exemplo n.º 2
0
def insert_autos(infile, db):
    autos = process_file(infile)

    # Your code here. Insert the data in one command
    # autos will be a list of dictionaries, as in the example in the previous video
    # You have to insert data in a collection 'autos'
    [db.autos.insert(e) for e in autos]
def test():
    data = process_file(DATAFILE, FIELDS)
    print "Your first entry:"
    pprint.pprint(data[0])
    first_entry = {
        "synonym":
        None,
        "name":
        "Argiope",
        "classification": {
            "kingdom": "Animal",
            "family": "Orb-weaver spider",
            "order": "Spider",
            "phylum": "Arthropod",
            "genus": None,
            "class": "Arachnid"
        },
        "uri":
        "http://dbpedia.org/resource/Argiope_(spider)",
        "label":
        "Argiope",
        "description":
        "The genus Argiope includes rather large and spectacular spiders that often have a strikingly coloured abdomen. These spiders are distributed throughout the world. Most countries in tropical or temperate climates host one or more species that are similar in appearance. The etymology of the name is from a Greek name meaning silver-faced."
    }

    assert len(data) == 76
    assert data[0] == first_entry
    assert data[17]["name"] == "Ogdenia"
    assert data[48]["label"] == "Hydrachnidiae"
    assert data[14]["synonym"] == ["Cyrene Peckham & Peckham"]
def insert_autos(infile, db):
    autos = process_file(infile)
    
    #num_autos = db.autos.find().count()
    #print "num_autos before insert:", num_autos
    
    for each in autos:
        db.autos.insert(each)
Exemplo n.º 5
0
def insert_autos(infile, db):
    autos = process_file(infile)

    #num_autos = db.autos.find().count()
    #print "num_autos before insert:", num_autos

    for each in autos:
        db.autos.insert(each)
Exemplo n.º 6
0
def write_to_json(infile, json_file):
    data = process_file(infile)

    # write item by item
    with open(json_file, "w") as jf:
        for a in data:
            json.dump(a, jf, indent=2)
            jf.write("\n")
    """
Exemplo n.º 7
0
def write_to_json(infile, json_file):
    data = process_file(infile)
    


    # write item by item
    with open(json_file, "w") as jf:
        for a in data:
            json.dump(a, jf, indent=2)
            jf.write("\n")
    """
Exemplo n.º 8
0
def insert_autos(infile, db):
    autos = process_file(infile)
    db.autos.insert(autos)
Exemplo n.º 9
0
def insert_autos(infile, db):
    autos = process_file(infile)
from autos import process_file
from pymongo import MongoClient
from pprint import pprint

client = MongoClient("mongodb://localhost:27017")
db = client.uda
# def insert_autos(infile, db):
     
    # Add your code here. Insert the data in one command.
    
  
if __name__ == "__main__":
    # Code here is for local use on your own computer.
    data = process_file('small_autos.csv')
    pprint(data)
    db.autos.insert(data)
    # insert_autos('small_autos.csv', db)
    pprint(db.autos.find_one())
Exemplo n.º 11
0
def insert_autos(infile, db):

    data = process_file(infile)
    for a in data:  # a is a dictionary
        db.autos.insert(a)  # question: difference between inserting a and data
Exemplo n.º 12
0
def insert_autos(infile, db):
    autos = process_file(infile)
    db.autos.insert(autos)
Exemplo n.º 13
0
from autos import process_file
from pymongo import MongoClient

client = MongoClient("mongodb://localhost:27017")
db = client.examples
col = db.autos

autos = process_file('autos.csv')
col.insert(autos)
Exemplo n.º 14
0
def insert_autos(infile, db):
    data = process_file(infile)
    # Add your code here. Insert the data in one command.
    db['autos'].insert(data)
Exemplo n.º 15
0
def insert_autos(infile, db):
    data = process_file(infile)
    # Insert the data in one command.
    # pprint.pprint(data)
    db.autos.insert(data)
def insert_autos(infile, db):
    data = process_file(infile)
    # Add your code here. Insert the data in one command.
    # nothing_list = [db.autos.insert(item) for item in data]
    db.autos.insert(data)
Exemplo n.º 17
0
def insert_autos(infile, db):
    data = process_file(infile)
    for a in data:
        db.autos.insert(a)
Exemplo n.º 18
0
def insert_autos(infile, db):
    data = process_file(infile)
def insert_autos(infile, db):
    autos = process_file(infile)

    for a in autos:
        db.autos.insert(a)
Exemplo n.º 20
0
def insert_autos(infile, db):
    autos = process_file(infile)

    # Your code here. Insert the data in one command
    for a in autos:
        db.autos.insert(a)
Exemplo n.º 21
0
def insert_autos(infile, db):
    data = process_file(infile)
    # Add your code here. Insert the data in one command.
    db.autos.insert(data)
Exemplo n.º 22
0
def insert_autos(infile, col):
    autos = process_file(infile)
    col.insert_many(autos)
Exemplo n.º 23
0
def insert_autos(infile, db):
    data = process_file(infile)
    # Add your code here. Insert the data in one command.
    for a in data:
        db.autos.insert_one(a)
def insert_autos(infile, db):
    data = process_file(infile)
    db.autos.insert(data)
Exemplo n.º 25
0
def insert_autos(infile, db):
    data = process_file(infile)
    pdb.set_trace()
    for mongo_row in data:
        db.autos.save(mongo_row)
Exemplo n.º 26
0
def insert_autos(infile, db):
    data = process_file(infile)
    for car in data:
        db.autos.insert(car)
Exemplo n.º 27
0
__author__ = "Miller"


from autos import process_file
from pymongo import MongoClient

client = MongoClient("mongodb://localhost:27017")
db = client.examples
col = db.autos

autos = process_file("autos.csv")
col.insert(autos)
Exemplo n.º 28
0
def insert_autos(infile, db):
    data = process_file(infile)
Exemplo n.º 29
0
def insert_autos(infile, db):
    autos = process_file(infile)
    for a in autos:
        db.autos.insert(a)
Exemplo n.º 30
0
def insert_autos(infile, db):
    data = process_file(infile)
    db.autos.insert(data)
Exemplo n.º 31
0
def insert_autos(infile, db):
    autos = process_file(infile)