来自CSV导入的MongoDB中的嵌套元素

时间:2017-08-10 10:06:58

标签: node.js mongodb csv nested

我有以下CSV文件:

Website Company name    City    State   Zip Country Founded year    Company email   Twitter Followers   Employees   Revenue Public/Private/Nonprofit    Industry    Monthly Technology Spend    First name  Last name   Title   Email   Confidence  Phone
website.com Some Company    Sydney  NSW 2010    Australia   2012    support@company.com 94750   100 - 250   $1 - 10M    Private Design  $5K - 20K   Fred    Smith   Mixing Technology and Accounting            
website.com Some Company    Sydney  NSW 2010    Australia   2012    support@company.com 94750   100 - 250   $1 - 10M    Private Design  $5K - 20K   Joe Bloggs  Secret Projects         
website.com Some Company    Sydney  NSW 2010    Australia   2012    support@company.com 94750   100 - 250   $1 - 10M    Private Design  $5K - 20K   Adam    Davids  Head of Growth  Adam@company.com    Grey    
website.com Some Company    Sydney  NSW 2010    Australia   2012    support@company.com 94750   100 - 250   $1 - 10M    Private Design  $5K - 20K   Angela  Johns   Senior Marketing Manager    angela@company.com  Grey    

数据似乎没有正确对齐,但我确定你明白了。

问题是你如何在csv中设置数据,以便你可以让mongoDB记录有一个URL

然后是一系列公司数据和员工数据。

   "URL" : Website.com
   "CompanyInfo" : [
    {
            "Company Name" : "",
            "City" : "",
            "State" : "",
            "Zip" : "",
             "Country" : "",
            "Founded year" : "",
            "company email" : "",
            "Twitter Followers" : "",
            "Employees" : "",
            "Revenue" : "",
            "Public/Private" : "",
            "Industry" : ""
            "Monthly Tech Spend" : ""
    }, etc...

"employees" : [
    {
            "First name" : "fred",
            "Last Name" : "Smith",
            "Title" : "Mixing Technology and Accounting",
            "Email" : "",
    }, etc... ]

记录示例可能不完美,但希望它可以让您了解我想要实现的目标

0 个答案:

没有答案