Automate it later on with a daily cronjob or another trigger.Merge longitude and latitude fields into a single field to be used as a 2d sphere index (for fast geo lookups).Leave out empty fields ( ignoreBlanks in mongoimport).Empty a cell in the CSV should remove the key in MongoDB.Remove a column in the CSV, should remove the key in each MongoDB document.Remove a row in the CSV, should remove the document in MongoDB.I like the spreadsheet as a single source of truth (SSOT) for the address data.In MongoDB Compass, you create a new collection and drop a CSV file, and in the shell, you can run mongoimport. Actually, there are plenty of ways to import a CSV in MongoDB. The most common and universal spreadsheet export format is CSV (Comma Separated Values). A document database seems a good fit for the project I’m working on. Easy (and free) to set up cloud service: MongoDB Atlas.Good documentation, tutorials, and a proven track record.Free tools with a pleasant UI, like MongoDB Compass.I chose MongoDB as database for several reasons: Instructions on installing and using the MongoDB PHP driver.Installing MongoDB Community edition locally.This will save you the local installation step. However, you can use the script with the free MongoDB Atlas instance too. I use the MongoDB PHP driver and a locally installed database (calling a remote Atlas instance felt too slow when developing). The downside of PHP is that it’s not really JSON friendly (query notation for MongoDB), so you need to rewrite the MongoDB queries into object/array notation for PHP. I picked PHP because I have the most experience with it, and it runs on any cheap shared web hosting service. In PHP, you have to rewrite the JSON operations in object/array notation. It’s a bit of a challenge with MongoDB because PHP is not that JSON-friendly. I use PHP because I’m most familiar with it. This article explains how I build a script to import CSV in MongoDB and keep it in sync with the same CSV file. Instead of building a User Interface to add addresses to a database, I like to keep track of all the data in an Excel/Google Sheets spreadsheet. I’m working on a store and business locator service.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |