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
133 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

+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
258 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
• 57,530 points
446 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
• 57,530 points
332 views
0 votes
1 answer

How to create and read from a temporary file in Python?

Hi, there is a very simple solution ...READ MORE

answered Jan 29, 2019 in Python by Nymeria
• 3,540 points
219 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
365 views
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
• 57,530 points
305 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,060 points
144 views