[SERVER-28631] Unable to query using FIRST KEY after dumping from csv file Created: 05/Apr/17  Updated: 31/May/17  Resolved: 06/Apr/17

Status: Closed
Project: Core Server
Component/s: Querying, Tools
Affects Version/s: 3.0.12
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Anil [X] Assignee: Kelsey Schubert
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File sample_dataset.csv    
Issue Links:
Duplicate
duplicates TOOLS-879 UTF-8 bom is not ignored in mongoimport Closed
Operating System: ALL
Steps To Reproduce:
  • Upload any CSV file
  • Query using first key from the file
Participants:

 Description   

The scenario is explained here http://stackoverflow.com/questions/43223253/mongodb-cannot-query-using-first-key-after-importing-data-from-csv-file. For whichever the keys in csv file, first key not usable for querying data.



 Comments   
Comment by Kelsey Schubert [ 06/Apr/17 ]

Hi anilCSE,

Thanks for the update. I'm going to close this as a duplicate of TOOLS-879.

Kind regards,
Thomas

Comment by Anil [X] [ 06/Apr/17 ]

Hi,
Sorry it was just typing mistake in stating the scenario(thought event can
lead to general keyword and may confuse), but in actual case I used same
"event" key to query it. I rechecked it, it's not working in 3.0.12. I have
updated mongodb after seeing some suggestions in stackoverflow, and it's
working fine with new versions.

On 7 Apr 2017 1:03 a.m., "Thomas Schubert (JIRA)" <jira@mongodb.org> wrote:

[ https://jira.mongodb.org/browse/SERVER-28631?page=com.atlass
ian.jira.plugin.system.issuetabpanels:comment-tabpanel&
focusedCommentId=1542939#comment-1542939 ]

Thomas Schubert commented on SERVER-28631:
------------------------------------------

Hi anilCSE,

Thanks for providing the data and command. To attempt to reproduce I
executed the following steps all with MongoDB 3.0.12.

  1. I started a fresh mongod.
  2. I executed the command above to use mongoimport to import the uploaded
    csv.
  3. Connected with mongo local-dev-db
  4. From the mongo shell, I performed the following commands

    {
            "_id" : ObjectId("58e6952355a6d051fda427b3"),
            "event" : "pageload",
            "id" : 4154,
            "date" : 1451607373,
            "browser" : "Explorer",
            "device" : "Mobile",
            "os" : "iOS",
            "country" : "Malaysia",
            "city" : "Kuala Lumpur",
            "referrer" : "homepage",
            "utm_source" : "",
            "utm_medium" : "",
            "utm_campaign" : "",
            "page_name" : "blog",
            "firstvisit_date" : 1451607371,
            "item_name" : "",
            "quantity" : "",
            "item_price" : "",
            "bill_amount" : "",
            "fail_reason" : ""
    }
    {
            "_id" : ObjectId("58e6952355a6d051fda427b3"),
            "event" : "pageload",
            "id" : 4154,
            "date" : 1451607373,
            "browser" : "Explorer",
            "device" : "Mobile",
            "os" : "iOS",
            "country" : "Malaysia",
            "city" : "Kuala Lumpur",
            "referrer" : "homepage",
            "utm_source" : "",
            "utm_medium" : "",
            "utm_campaign" : "",
            "page_name" : "blog",
            "firstvisit_date" : 1451607371,
            "item_name" : "",
            "quantity" : "",
            "item_price" : "",
            "bill_amount" : "",
            "fail_reason" : ""
    }
    null
    

After examining the csv, I see that the column name is event.
Therefore, the results from my reproduction attempt mach my expectations
for how MongoDB ought to behave. Would you please review the steps above
and let me know if you are seeing a different result?

Thank you,
Thomas

tions/43223253/mongodb-cannot-query-using-first-key-after-
importing-data-from-csv-file]. For whichever the keys in csv file, first
key not usable for querying data.

----------------------
This message was sent from MongoDB's issue tracking system. To respond to
this ticket, please login to https://jira.mongodb.org using your JIRA or
MMS credentials.

Comment by Kelsey Schubert [ 06/Apr/17 ]

Hi anilCSE,

Thanks for providing the data and command. To attempt to reproduce I executed the following steps all with MongoDB 3.0.12.

  1. I started a fresh mongod.
  2. I executed the command above to use mongoimport to import the uploaded csv.
  3. Connected with mongo local-dev-db
  4. From the mongo shell, I performed the following commands

    > db.datastore.findOne()
    {
    	"_id" : ObjectId("58e6952355a6d051fda427b3"),
    	"event" : "pageload",
    	"id" : 4154,
    	"date" : 1451607373,
    	"browser" : "Explorer",
    	"device" : "Mobile",
    	"os" : "iOS",
    	"country" : "Malaysia",
    	"city" : "Kuala Lumpur",
    	"referrer" : "homepage",
    	"utm_source" : "",
    	"utm_medium" : "",
    	"utm_campaign" : "",
    	"page_name" : "blog",
    	"firstvisit_date" : 1451607371,
    	"item_name" : "",
    	"quantity" : "",
    	"item_price" : "",
    	"bill_amount" : "",
    	"fail_reason" : ""
    }
    > db.datastore.findOne({"event":"pageload"})
    {
    	"_id" : ObjectId("58e6952355a6d051fda427b3"),
    	"event" : "pageload",
    	"id" : 4154,
    	"date" : 1451607373,
    	"browser" : "Explorer",
    	"device" : "Mobile",
    	"os" : "iOS",
    	"country" : "Malaysia",
    	"city" : "Kuala Lumpur",
    	"referrer" : "homepage",
    	"utm_source" : "",
    	"utm_medium" : "",
    	"utm_campaign" : "",
    	"page_name" : "blog",
    	"firstvisit_date" : 1451607371,
    	"item_name" : "",
    	"quantity" : "",
    	"item_price" : "",
    	"bill_amount" : "",
    	"fail_reason" : ""
    }
    > db.datastore.findOne({"event_name":"pageload"})
    null
    

After examining the csv, I see that the column name is event. Therefore, the results from my reproduction attempt mach my expectations for how MongoDB ought to behave. Would you please review the steps above and let me know if you are seeing a different result?

Thank you,
Thomas

Comment by Anil [X] [ 05/Apr/17 ]

Hi @Thomas,

Here is the command I used to import into db:

mongoimport --db local-dev-db --collection datastore --type csv --headerline --file ~/sample_dataset.csv

Please find the attachment above for sample dataset

Comment by Kelsey Schubert [ 05/Apr/17 ]

Hi anilCSE,

Would you please provide attach a sample csv and the exact command used to import the data into MongoDB?

Thank you,
Thomas

Generated at Thu Feb 08 04:18:39 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.