end-of-line

splitlines() and iterating over an opened file give different results

霸气de小男生 提交于 2021-01-29 06:14:55
问题 I have files with sometimes weird end-of-lines characters like \r\r\n . With this, it works like I want: with open('test.txt', 'wb') as f: # simulate a file with weird end-of-lines f.write(b'abc\r\r\ndef') with open('test.txt', 'rb') as f: for l in f: print(l) # b'abc\r\r\n' # b'def' I want to able to get the same result from a string . I thought about splitlines but it does not give the same result: print(b'abc\r\r\ndef'.splitlines()) # [b'abc', b'', b'def'] Even with keepends=True , it's

Python readline with custom delimiter

谁说胖子不能爱 提交于 2020-12-05 04:55:28
问题 novice here. I am trying to read lines from a file, however a single line in a .txt file has a \n in the middle somewhere and while trying to read that line with .readline python cuts it in the middle and outputs as two lines. when I copy and past the line to this window, it shows up as two lines. So i uploaded the file here: https://ufile.io/npt3n also added screenshot of the file as it shows in txt file. this is group chat history exported from Whatsup..if you are wondering. Please help me

Convert all EOL (dos->unix) of all files in a directory and sub-directories recursively without dos2unix

左心房为你撑大大i 提交于 2020-01-10 07:43:18
问题 How do I convert all EOL (dos->unix) of all files in a directory and sub-directories recursively without dos2unix ? (I do not have it and cannot install it.) Is there a way to do it using tr -d '\r' and pipes? If so, how? 回答1: For all files in current directory you can do it with a Perl one-liner: perl -pi -e 's/\r\n/\n/g' * (stolen from here) EDIT : And with a small modification you can do subdirectory recursion: find | xargs perl -pi -e 's/\r\n/\n/g' 回答2: You can use sed's -i flag to change

Convert all EOL (dos->unix) of all files in a directory and sub-directories recursively without dos2unix

隐身守侯 提交于 2020-01-10 07:43:09
问题 How do I convert all EOL (dos->unix) of all files in a directory and sub-directories recursively without dos2unix ? (I do not have it and cannot install it.) Is there a way to do it using tr -d '\r' and pipes? If so, how? 回答1: For all files in current directory you can do it with a Perl one-liner: perl -pi -e 's/\r\n/\n/g' * (stolen from here) EDIT : And with a small modification you can do subdirectory recursion: find | xargs perl -pi -e 's/\r\n/\n/g' 回答2: You can use sed's -i flag to change

jsoup to strip only html tags not new line character?

烂漫一生 提交于 2019-12-30 12:13:20
问题 I have below content in Java where I want to strip only html tags but not new line characters <p>test1 <b>test2</b> test 3 </p> //line 1 <p>test4 </p> //line 2 If I open above content in text rich editor, line 1 and line 2 are displayed in different lines(without showing </p> tag).But in notepad content is shown along with </p> tags. To remove all html tags I used Jsoup.parse(aboveContent).text() It removes all html characters. But it shows all line 1 and line 2 in same line in notepad.

jsoup to strip only html tags not new line character?

荒凉一梦 提交于 2019-12-30 12:13:07
问题 I have below content in Java where I want to strip only html tags but not new line characters <p>test1 <b>test2</b> test 3 </p> //line 1 <p>test4 </p> //line 2 If I open above content in text rich editor, line 1 and line 2 are displayed in different lines(without showing </p> tag).But in notepad content is shown along with </p> tags. To remove all html tags I used Jsoup.parse(aboveContent).text() It removes all html characters. But it shows all line 1 and line 2 in same line in notepad.

removing EOL delimiter from inserting into external table -oracle

别来无恙 提交于 2019-12-25 04:20:00
问题 I have included notrim for rowdata column in external table as suggesterd by Alex (This is a continuation of this question,), But now End of Line character is also appending at the rowdata column , I mean , End of line (CR-LF) is also joins at the end of rowdata. I don't want to use substr() or translate() , since file size is around 1GB, My external table creation process : 'CREATE TABLE ' || rec.ext_table_name || ' (ROW_DATA VARCHAR2(4000)) ORGANIZATION EXTERNAL ' || '(TYPE ORACLE_LOADER

Portable end of line

ぃ、小莉子 提交于 2019-12-23 06:49:18
问题 is there any way to automatically use correct EOL character depending on the OS used? I was thinking of something like std::eol ? I know that it is very easy to use preprocessor directives but curious if that is already available. What I am interested in is that I usually have some messages in my applications that I combine later into a single string and I want to have them separated with a EOL. I know that I could use std::stringstream << endl but it seems to be an overkill sometimes instead

NSAttributedString '\n' ignored

白昼怎懂夜的黑 提交于 2019-12-22 03:21:54
问题 I have a single view whose only UI element is a UITextView . In viewDidLoad: I create an attributed string with "Text\n" and set the text view's attributed text as such: NSAttributedString *string = [[NSAttributedString alloc] initWithString:@"Text\n"]; [self.textView setAttributedText:string]; My problem is that the line break is ignored when I run the app. If I use an NSString and setText: that doesn't happen. NSString *string = [[NSString alloc] initWithString:@"Text\n"]; [self.textView

Vim no end of line on last line or eof

核能气质少年 提交于 2019-12-20 08:58:14
问题 I am trying to setup vim to skip adding eol on last line or eof, i have tried this :set binary :set noeol :w which is not perfect cause binary override filetype for later use. Any other option to set this, i don't need newline on last line. 回答1: I wanted to add an answer that I think can be as useful. The selected answer always remove the EOL on files even if they had one to begin with. This may be the behavior that you want, it also may not be. In my opinion I want to preserve the EOL as I