How to sort json file ascending in pymongo

0 votes
I want to sort json file Ascending or Descending after connect on pymongo, and I have this problem ...

when is use this code :

db.data.find()

or this code :

cars = db.cars.find().sort("price", DESCENDING)

I got this message :

<pymongo.cursor.Cursor object at 0x7f4b50315890>
Aug 14, 2019 in Python by Ahmed
• 310 points
723 views

1 answer to this question.

0 votes

Hey Ahmad, you can get the output by iterating over your curser.

for row in cars
    print(row)
answered Aug 14, 2019 by Trisha

Related Questions In Python

0 votes
1 answer

How to order_by a JSON from serializers.py file in django rest framework?

Hello @kartik, There's an easy way, just override ...READ MORE

answered Jul 2, 2020 in Python by Niroj
• 82,880 points
5,343 views
+1 vote
1 answer

how to convert json to csv or to store in sql

You can convert JSON data to csv ...READ MORE

answered Jul 2, 2018 in Python by Nietzsche's daemon
• 4,260 points
1,891 views
0 votes
1 answer

How to read Excel File in Python

With pandas it is possible to get ...READ MORE

answered Oct 22, 2018 in Python by Priyaj
• 58,090 points
1,522 views
0 votes
1 answer

how to read a JSON from a file?

You can use with statement with open('strings.json') as ...READ MORE

answered Oct 24, 2018 in Python by Priyaj
• 58,090 points
5,206 views
+2 votes
1 answer
0 votes
1 answer

How to import json file to mongodb using pyspark (or python)?

You can use the same format as ...READ MORE

answered Sep 9, 2019 in Python by Karan
1,609 views
0 votes
2 answers
0 votes
1 answer

How to Parse values from a JSON file?

import json from pprint import pprint with open('data.json') as ...READ MORE

answered Oct 15, 2018 in Python by Priyaj
• 58,090 points
1,636 views
0 votes
1 answer

How to check latest change time of each file using glob in python?

You can get the changing time from ...READ MORE

answered Jan 2, 2019 in Python by Omkar
• 69,210 points
1,092 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP