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

Popular posts from this blog

css - I want to align grid in center -

python - SWIG function not printing output -

oop - Function for all prototypes - Javascript -