暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

在MongoDB中导入样本数据

原创 库海无涯 2024-08-15
176

##

在MongoDB中导入样本数据

1、样本数据导入

官方推荐的样本数据:https://insideairbnb.com/get-the-data/

[root@mongodb01 ~]# gzip -d listings.csv.gz

[root@mongodb01 ~]# mongoimport -d db01 --type=csv listings.csv
2024-08-15T09:20:40.605+0800    error validating settings: must specify --fields, --fieldFile or --headerline to import this file type

[root@mongodb01 ~]# mongoimport -d db01 --type=csv --headerline listings.csv
2024-08-15T09:20:49.405+0800    no collection specified
2024-08-15T09:20:49.405+0800    using filename 'listings' as collection
2024-08-15T09:20:49.410+0800    connected to: mongodb://localhost/
2024-08-15T09:20:49.528+0800    402 document(s) imported successfully. 0 document(s) failed to import.

[root@mongodb01 ~]# mongosh
Current Mongosh Log ID: 66bd57fa5a17878ad3482f8a
Connecting to:          mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.2.12
Using MongoDB:          7.0.12
Using Mongosh:          2.2.12
mongosh 2.2.15 is available for download: https://www.mongodb.com/try/download/shell

For mongosh info see: https://docs.mongodb.com/mongodb-shell/

------
   The server generated these startup warnings when booting
   2024-08-15T08:49:16.945+08:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
------

Enterprise test> use db01
switched to db db01

Enterprise db01> show collections;
listings
tab01
tab02

Enterprise db01> db.listings.find().count()
402

Enterprise db01> db.listings.findOne()
{
  _id: ObjectId('66bd57f13a3588db3021713c'),
  id: 2992450,
  listing_url: 'https://www.airbnb.com/rooms/2992450',
  scrape_id: Long('20240607164239'),
  last_scraped: '2024-06-07',
  source: 'city scrape',
  name: 'Luxury 2 bedroom apartment',
  description: "The apartment is located in a quiet neighborhood . Fully furnished. Linens and towels are provided. It's two blocks away from downtown Albany, and the Palace theater.",
  neighborhood_overview: '',
  picture_url: 'https://a0.muscache.com/pictures/44627226/0e72c75c_original.jpg',
  host_id: 4621559,
  host_url: 'https://www.airbnb.com/users/show/4621559',
  host_name: 'Kenneth',
  host_since: '2013-01-07',
  host_location: 'New York, NY',
  host_about: 'I am a real down to earth & cool person.',
  host_response_time: 'within a few hours',
  host_response_rate: '100%',
  host_acceptance_rate: '100%',
  host_is_superhost: 'f',
  host_thumbnail_url: 'https://a0.muscache.com/im/users/4621559/profile_pic/1363081467/original.jpg?aki_policy=profile_small',
  host_picture_url: 'https://a0.muscache.com/im/users/4621559/profile_pic/1363081467/original.jpg?aki_policy=profile_x_medium',
  host_neighbourhood: '',
  host_listings_count: 1,
  host_total_listings_count: 5,
  host_verifications: "['email', 'phone']",
  host_has_profile_pic: 't',
  host_identity_verified: 'f',
  neighbourhood: '',
  neighbourhood_cleansed: 'THIRD WARD',
  neighbourhood_group_cleansed: '',
  latitude: 42.65789,
  longitude: -73.7537,
  property_type: 'Entire rental unit',
  room_type: 'Entire home/apt',
  accommodates: 4,
  bathrooms: 1,
  bathrooms_text: '1 bath',
  bedrooms: 2,
  beds: 2,
  amenities: '["Essentials", "Air conditioning", "Wifi", "Kitchen", "TV with standard cable", "Smoke alarm", "Carbon monoxide alarm", "Heating"]',
  price: '$70.00',
  minimum_nights: 28,
  maximum_nights: 1125,
  minimum_minimum_nights: 28,
  maximum_minimum_nights: 28,
  minimum_maximum_nights: 1125,
  maximum_maximum_nights: 1125,
  minimum_nights_avg_ntm: 28,
  maximum_nights_avg_ntm: 1125,
  calendar_updated: '',
  has_availability: 't',
  availability_30: 0,
  availability_60: 0,
  availability_90: 0,
  availability_365: 68,
  calendar_last_scraped: '2024-06-07',
  number_of_reviews: 9,
  number_of_reviews_ltm: 0,
  number_of_reviews_l30d: 0,
  first_review: '2014-07-01',
  last_review: '2022-08-17',
  review_scores_rating: 3.56,
  review_scores_accuracy: 3.44,
  review_scores_cleanliness: 3.56,
  review_scores_checkin: 4.22,
  review_scores_communication: 4.56,
  review_scores_location: 3.22,
  review_scores_value: 3.67,
  license: '',
  instant_bookable: 'f',
  calculated_host_listings_count: 1,
  calculated_host_listings_count_entire_homes: 1,
  calculated_host_listings_count_private_rooms: 0,
  calculated_host_listings_count_shared_rooms: 0,
  reviews_per_month: 0.07
}
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论