I am importing a CSV file into my Mongo collection and it is getting imported successfully. This is my Windows Command Prompt execution:
mongoimport --host localhost --db testing --collection test1 --type csv --headerline --file Desktop\try.csv
2016-10-12T23:25:10.464+0530 connected to: localhost
2016-10-12T23:25:10.561+0530 imported 1 document
My collection shows the following:
> db.test1.find().pretty()
{
"_id" : ObjectId("57fe78fece1854fc74ad37f0"),
"class" : "7th",
"school_id" : 1
}
{
"_id" : ObjectId("57fe7975912ee1426d6d94c6"),
"school_id" : "1",
"class" : "5th"
}
{
"_id" : ObjectId("57fe7980912ee1426d6d94c7"),
"school_id" : "1",
"class" : "6th"
}
Here I have only imported the document with class 7th. The documents with class 5th and 6th have been inserted through Mongo Shell and not imported.
Now in PHP when I try to retrieve these documents, and display the "class" of each document, I am only able to display classes 5th and 6th which I inserted through Mongo Shell. The imported document data is not displayed i.e. class 7th.
I tried something with "writeConcern":
mongoimport --host localhost --db testing --collection test1 --type csv --headerline --file Desktop\try.csv --writeConcern {w:"majority"}
Is this something related to read or write concerns of MongoDB? Or something concerning the PHP Mongo driver?
I have a lot of data and I cannot afford to insert it through shell.
(I am using XAMPP Windows)
There is a difference between the data. The school_id is a number in 7th and a string in 5th and 6th. Is this causing a problem in your query?