{"id":13040,"date":"2021-12-11T14:18:47","date_gmt":"2021-12-11T14:18:47","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=13040"},"modified":"2021-12-11T14:19:07","modified_gmt":"2021-12-11T14:19:07","slug":"solved-insert-a-carriage-return-into-a-txt-file","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/insert-a-carriage-return-into-a-txt-file\/21856.html","title":{"rendered":"Solved Insert a Carriage Return Into a Txt File"},"content":{"rendered":"<p>Hi all.<br \/>\nI believe I have a challenge for you all today.<br \/>\nBasically I just need to insert a carriage return into a txt file before a certain (known ) string using a .bat file. Basically the txt file has about 2000 records clumped together. The findstr would be perfect as I am looking for the reference number of the user, but the findstr just returns the entire file as there are no carriage returns. I need to insert a carriage return before every instance of the word \u201cheader\u201d and after every instance of the word \u201cMTR\u201d.If I can get the carriage return in those places it would be great because the findstr will return every bit of the record between the \u201cHeader\u201d and \u201cMTR\u201d.<br \/>\nHowever as easy as this may sound there are a few catches.<br \/>\n1. there are currently no carriage returns in the file.<br \/>\n2.The file is about 70mb<br \/>\n3.Although there are delimiters in the file, the actual number of delimiters changes per record and is always well above the 26 allowed by tokens.<br \/>\n4.there are a huge number of lines (over 2000 a4 pages) worth of records, using a loop would be inpractable ?<br \/>\n5.Findstr just returns the entire txt file because there are no carriage returns<br \/>\n6.There are about 2000 instances of the word \u201cheader\u201d<\/p>\n<p>Sample format<br \/>\nHeader\u2019there is just so\u2019much text that : goes here and the \u2018amount of dilimiters\u2019? is just socrazy\u2019the RECORD NUMBER MAYBE BOUT HERE+and then there would be more stuff.This\u2227 the dilimiters would:go on a further+50lines\u2019before it hits the\u2019MTR\u2019Header:and were off again for another record of 50 lines\u2019MTR<br \/>\nThe final appearance (if possible to export into a .txt file with changes ?) it to look like the below as the find str will grab everything between the \u201cheader\u201d and \u201cMTR\u201d.the RECORD NUMBER will be based on user input but I can do that.Here is what im hoping for<\/p>\n<p>Header\u2019there is just so\u2019much text that : goes here and the \u2018amount of dilimiters\u2019? is just socrazy\u2019the RECORD NUMBER MAYBE BOUT HERE+and then there would be more stuff.This\u2227 the dilimiters would:go on a further+50lines\u2019before it hits the\u2019MTR\u2019<\/p>\n<p>Header\u2019there is just so\u2019much text that : goes here and the \u2018amount of dilimiters\u2019? is just socrazy\u2019the RECORD NUMBER MAYBE BOUT HERE+and then there would be more stuff.This\u2227 the dilimiters would:go on a further+50lines\u2019before it hits the\u2019MTR\u2019<\/p>\n<p>Header\u2019there is just so\u2019much text that : goes here and the \u2018amount of dilimiters\u2019? is just socrazy\u2019the RECORD NUMBER MAYBE BOUT HERE+and then there would be more stuff.This\u2227 the dilimiters would:go on a further+50lines\u2019before it hits the\u2019MTR\u2019<\/p>\n<p>Thanks a million if you can help<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":4},"question-category":[55],"question_tags":[],"class_list":["post-13040","question","type-question","status-publish","hentry","question-category-programming"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/13040","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=13040"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=13040"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=13040"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=13040"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}