1. Export to CSV file:
2. Import from CSV:
data is exported through CSV export, there is a very hidden problem , you need to note when writing code:
Pilot into one data:
Where Price is a double type:
Then I export the record to demo.csv and delete the record from the database, and then import the record from Demo.csv:
Then look at this record in the database:
found that the price value of the original double type 66.000000 automatically became the Int32 type 66.
When the problem arises , you will not get a value if you still use Bson_iter_double (&iter) to fetch the Price field:
The value can only be taken with Bson_iter_int32 (&iter):
so get the conclusion :
When you need to fetch a field of type float (or double) in your data, the code should be written as follows:
Avoid issues where the field values are not taken after the data has been exported to CSV and then imported from CSV.
MongoDB CSV file Import and Export