-
Notifications
You must be signed in to change notification settings - Fork 0
/
import.txt
30 lines (25 loc) · 1021 Bytes
/
import.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
mongoimport -d mydb -c results --type csv --file poolA-n-2.csv --headerline TOS
//Below is the command to convert all the numlong phone numbers which I had faced some difficulty in querying using monk, so instead of searching around I thought to convert all of them into strings
db.results.find({}).forEach(function(doc) {
if(!isNaN(doc['Phone Number'])) {
print('found string: ' + doc._id);
db.results.update(
{ _id: doc._id},
{ $set : { "Phone Number" : doc['Phone Number'].toString().match(/\d+/)[0] } }
)
}
})
db.results.find({}).forEach(function(doc) {
if(doc.hasOwnProperty('RollNo')) {
print('found string: ' + doc._id);
db.results.update(
{ _id: doc._id},
{ $set : { "Rollno" : doc['RollNo'] } }
)
}
})
db.results.find({}).count()
db.results.update(
{ _id: doc._id},
{ $set : { "Phone Number" : doc['Phone Number'].toString().match(/\d+/)[0] } }
)