Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

28 lines (22 sloc) 0.631 kb
#!/usr/bin/env ruby
require 'rubygems'
require 'mongo'
require 'csv'
conn = Mongo::Connection.new
db = conn.db("wargraves")
collection = db.collection("casualties")
cursor = collection.find()
out = File.open("casualties.csv","w")
fields = ["casualty_id", "name", "citation", "age", "death", "regiment", "nationality", "service", "awards", "initials", "unittext2", "rank", "information", "grave", "type", "cemetery", "unittext", "regiment2"]
out.puts CSV.generate_line(fields)
cursor.each do |r|
values = fields.map {|f|
if r[f]
r[f]
else
""
end
}
out.puts CSV.generate_line(values)
end
out.close
Jump to Line
Something went wrong with that request. Please try again.