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

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -