Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8408621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:41:01+00:00 2026-06-09T23:41:01+00:00

I have a file with data in the json format. The data is odd

  • 0

I have a file with data in the json format. The data is odd in that the rows have varying subsets of a set of properties that are not all known in advance (over time they will build up). For example:

[{"firstName":"Joe","education":"highschool","sex":"male"},
 {"lastName":"Edwards","address":"ohio","sex":"male"},
{"favoriteSport":"cycling","bicycle":"raleigh","ownsBoat":"yes","ownsDog":"yes","ownsHouse":"yes"}]

A large amount of data exists already in a file so I would like to import it in to couchdb rather than enter the data item by item. I followed the procedures from a post here but, while a db was created, it was empty. I used:

curl -X PUT -d @../Data/data.json http://127.0.0.1:5984/test_import

UPDATE: Since I’m working with nodejs (newbie), I thought I’d try using ‘cradle’. My thought was to take the import the data as an array, and bulk load that using ‘cradle’s dbsave(). But using the following:

var fs = require('fs');
var cradle = require('cradle');

var data = fs.readFile( '../Data/data.json', function (err, data) {
  if (err) {
    throw err; 
  }
.
.
.
makeDB(bigdata,'test_import');  // where 'bigdata' is an array of json objects/couchdb 'documents'
});

function makeDB (p,filename) {

var db = new(cradle.Connection)().database(filename);
console.log(db);

db.save(p, function(err,res) {
if (err) {
    console.log(err);
} else {
    console.log('Success!');
}
});

};

The latter seems to work!! A database is created and filled but it does however throw the following errors:

k:\nodejs\node_modules\cradle\lib\cradle.js:198
            return callback(body);
                   ^
TypeError: undefined is not a function

OR

k:\nodejs\node_modules\cradle\lib\cradle.js:201
        callback(null, self.options.raw ? body : new cradle.Response(body, res
        ^
TypeError: undefined is not a function
    at Request.cradle.Connection.request [as _callback] (k:\nodejs\node_modules\cradle\lib\cradle.
js:201:9)
    at Request.init.self.callback (k:\nodejs\node_modules\request\main.js:120:22)
    at Request.EventEmitter.emit (events.js:91:17)
    at Request.<anonymous> (k:\nodejs\node_modules\request\main.js:633:16)
    at Request.EventEmitter.emit (events.js:88:17)
    at IncomingMessage.Request.start.self.req.self.httpModule.request.buffer (k:\nodejs\node_modul
es\request\main.js:595:14)
    at IncomingMessage.EventEmitter.emit (events.js:115:20)
    at IncomingMessage._emitEnd (http.js:366:10)
    at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23)
    at Socket.socketOnData [as ondata] (http.js:1366:20)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:41:02+00:00Added an answer on June 9, 2026 at 11:41 pm

    [SOLVED]

    The answers to my questions are that yes, of course, couchdb is perfectly suited to that kind of data. The easiest way I found to do the bulk import with node.js is using cradle (whose creator provided solution to problem). The preceding code works error free with the following changes to the makeDB function:

    //  Take the array of objects and create a couchdb database
    
    function makeDB (data,filename) {
    
    var db = new(cradle.Connection)().database(filename);
    //console.log(db);
    db.create(function(err){
        if (err) console.log(err); 
        });
    db.save(data, function(err) {
        if (err) console.log(err);
        console.log(filename + ' is created.');
        });
    
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text file that contains cached data in JSON format. I'm trying
If i have a php file that outputs json data with numerical keys, like
I have some json data existed in a php file that needs to be
I have some data in JSON format in a text file as below. I
I have a flash file which loads data from JSON and parses it. It
I have a json file of data and the only item for time i
I have written java code for generating json of my searched data from file.But
I have some data and need to create a json file with this structure
I have a data file that looks like this: xyz123 2.000 -0.3974 0.0 hij123
I have a link that opens up JSON data in the browser, but unfortunately

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.