This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df.to_csv('StructuredData.csv',index=False) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
samples=table.find().sort("_id",pymongo.DESCENDING)[:100] | |
df=pd.DataFrame(samples) | |
df.head() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
testInsert=mycoll.insert_one({"country":'India'}).inserted_id | |
client.list_database_names() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mydb=client.testDB | |
mycoll=mydb.testColl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myquery = ({ "name":{"$in": ["Gyan","Eliot"]}}) | |
x = table.delete_many(myquery) | |
print(x.deleted_count, " documents deleted.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
table.delete_one({'name':'Mike'}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
table.find_one({'name':'Mike'}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bson.objectid import ObjectId | |
post_id=final.inserted_ids[0] | |
def parser(post_id): | |
document = table.find_one({'_id': ObjectId(post_id)}) | |
return document | |
parser(post_id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
table.find_one({"name":'Gyan'}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
new_posts = [{"name": "Mike", | |
"username": "latestpost!", | |
"date": datetime.datetime(2009, 11, 12, 11, 14)}, | |
{"name": "Eliot", | |
"title": "onceAgain", | |
"text": "and pretty easy too!", | |
"date": datetime.datetime(2009, 11, 10, 10, 45)}] | |
final = table.insert_many(new_posts) |
NewerOlder