-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3b6796
commit 57d72a6
Showing
3 changed files
with
171,061 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
var fs = require('fs'); | ||
|
||
if (process.argv.length !== 4) { | ||
console.log("USAGE: node convert.js infile outfile"); | ||
process.exit(1); | ||
} | ||
|
||
var inFile = process.argv[2], | ||
outFile = process.argv[3]; | ||
|
||
|
||
var inData = fs.readFileSync(inFile, 'utf8'); | ||
|
||
var lines = inData.split("\n"); | ||
|
||
var out = "create_collection('us_cities');\n"; | ||
|
||
for (var i = 0; i < lines.length; i++) { | ||
var parts = lines[i].split(","); | ||
|
||
var obj = { | ||
"Country": parts[0], | ||
"City": parts[1], | ||
"Region": parts[2], | ||
"Latitude": Number(parts[3]), | ||
"Longitude": Number(parts[4]) | ||
}; | ||
|
||
out += "SELECT save('us_cities', '" + JSON.stringify(obj) + "');\n"; | ||
} | ||
|
||
fs.writeFileSync(outFile, out, 'utf8'); | ||
|
||
console.log("done!"); |
Oops, something went wrong.