Created
March 3, 2014 18:08
-
-
Save Karunamon/9331001 to your computer and use it in GitHub Desktop.
Appends month/day/year fields to CSV files - useful because you apparently can't target blog entries by title in Confluence CLI without specifying their date separately.
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
#!/usr/bin/env ruby | |
#Add date fields for mass operations on blogs with Atlassian CLI. | |
#WTFPL | |
require "csv" | |
fail "Specify path to input file" unless ARGV[0] | |
fail "Specify path to output file" unless ARGV[1] | |
hdr=true | |
CSV.open(ARGV[1], 'w') do |csv| | |
CSV.foreach(ARGV[0], :headers => true, :skip_blanks => true) do |row| | |
date = row["Created"].match(/(?<month>\d+)\/(?<day>\d+)\/(?<year>\d+)/) | |
row << ['month', date[:month]] | |
row << ['day', date[:day]] | |
row << ['year', date[:year]] | |
csv << row.headers if hdr | |
csv << row | |
hdr = false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment