Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Export the data from Google Docs to a CSV file.</p> <pre><code>gdocs.csv </code></pre> <p>Create a file describing the CSV file - one line per field in the CSV file. <code>gdocsFields.txt</code> could look like this:</p> <pre><code>key number </code></pre> <p>Import the data into your mongo instance in a temporary collection, e.g. <code>temp</code>:</p> <pre><code>mongoimport --type csv -c temp --fieldFile gdocsFields.txt &lt; gdocs.csv </code></pre> <p>Now update your live collection, e.g. <code>live</code> with a query from the mongo console. Have a look at this example that also creates the imported data for you for testing. It pastes directly in to the <code>mongo</code> console:</p> <pre><code>db.temp.drop(); db.live.drop(); db.temp.insert({key:'abc', number:111}); db.temp.insert({key:'foo', number:222}); db.temp.insert({key:'xxx', number:333}); db.temp.insert({key:'yyy', number:444}); db.temp.insert({key:'zzz', number:555}); db.live.insert({key:'abc', number:100}); db.live.insert({key:'foo', number:200}); db.live.insert({key:'xxx', number:300}); db.live.insert({key:'yyy', number:400}); db.live.insert({key:'zzz', number:500}); // Update every record var keys = db.temp.find(); keys.forEach(function(doc){ db.live.update( { key:doc.key }, { $set: {number:doc.number} }, { upsert: true } ); print(doc.key); }); // Print out the live collection var keys = db.live.find(); keys.forEach(function(doc){ print(doc.key + " is now: " + doc.number); }); </code></pre> <p>Not the most efficient way but it should be easy to follow the process.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload