mongoimport 将数据类型应用为所有字段的字符串

问题描述 投票:0回答:1

当我们导入 CSV 文件数据时

mongodimport
会自动为每个字段选择数据类型。

是否可以将数据类型应用为所有字段的字符串? --columnsHaveTypes 可以帮助定义字段类型。但我不想手动定义每个字段并键入。

这是我的 schel 脚本:

cd <path to direcotry of csv files>
$files = Get-ChildItem .
foreach ($f in $files) {
  if ($f -Like "*.csv") {
   mongoimport -d mydb -c mycollection --type csv --file $f --headerline
 }
}

感谢您的帮助!

mongodb mongodb-.net-driver
1个回答
0
投票

PS C:\Users\dell> mongodimport --uri mongodb+srv://shahbaztube9654:[电子邮件受保护]/GoFood --collection food_items -- jsonArray --file "D:\me\web dev\practice oodCategory .json” mongodimport :术语“mongodimport”不被识别为 cmdlet、函数、脚本文件或可操作程序的名称。检查拼写 名称,或者如果包含路径,请验证路径是否正确,然后重试。 在行:1 字符:1

  • mongodimport --uri mongodb+srv://shahbaztube9654:gMnSFcebu2xIhCXD@clu ...
  •   + CategoryInfo          : ObjectNotFound: (mongodimport:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    
    
    
    

如何修复 mongod 命令正在工作,但该命令不起作用

© www.soinside.com 2019 - 2024. All rights reserved.