mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-26 01:15:27 +00:00
24 lines
486 B
Ruby
24 lines
486 B
Ruby
#!/usr/bin/env ruby
|
|
|
|
require 'dkvp_io'
|
|
|
|
ARGF.each do |line|
|
|
# Read the original record:
|
|
map = dkvpline2map(line.chomp, '=', ',')
|
|
|
|
# Drop a field:
|
|
map.delete('x')
|
|
|
|
# Compute some new fields:
|
|
map['ab'] = map['a'] + map['b']
|
|
map['iy'] = map['i'] + map['y']
|
|
|
|
# Add new fields which show type of each already-existing field:
|
|
keys = map.keys
|
|
keys.each do |key|
|
|
map['t'+key] = map[key].class
|
|
end
|
|
|
|
# Write the modified record:
|
|
puts map2dkvpline(map, '=', ',')
|
|
end
|