Mongodb - Mongoimport error invalid character

前端 未结 6 2076
时光取名叫无心
时光取名叫无心 2020-12-19 01:35

I tried to import a simple json file using mongoimport and i get the following error

PER-MacBook-Pro:/AJ$ mongoimport --db test --collection samplePM --file         


        
6条回答
  •  感动是毒
    2020-12-19 02:15

    I was getting Failed: error processing document #112783: invalid character ',' looking for beginning of value because one of my objects was formatted improperly. Notice how "psychosurgery" is missing curly braces:

    {
      "word": "psychosurgeons",
      "firstLetter": "p"
    }
      " psychosurgery",
    {
      "word": "psychosurgical",
      "firstLetter": "p"
    }
    

    Since there are over 600,000 lines in the file I'm trying to import, this would have been tough to find manually.

    So I ran the same mongoimport command with full verbosity (-vvvvv) enabled, and the script stopped right on the problematic object. See mongoimport --help for more info.

    Hope this helps someone.

提交回复
热议问题