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

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -