Split file into two tempfiles in ruby -
i have large file 2 different formats separated dashed line, how can split file 2 tempfiles processing?
example:
yaml:format yaml:format yaml:format --------- csv,format csv,format etc.
split @ twelve dashes:
yaml, csv = input.split('------------', 2)
or @ variable number of dashes
yaml, csv = input.split(/^-+$/, 2)
this produce empty lines around delimiter (end of yaml
, start of csv
), if want rid of them can do
yaml, csv = input.split(/[\r\n]+^-+$[\r\n]+/, 2)
Comments
Post a Comment