Change string to only one line i csv - csv

I have csv file where each record is one line. Problem is that sometimes one cell have few lines. For example:
first;second;third;something something something something;four
first;second;third;something
something
something something;four
I opened this in Notepad++ and i see that end of record has LF white tag and new lines in cell has CR white tag.
How can I remove this CR white tags? I would like to have after convert:
first;second;third;something something something something;four
first;second;third;something something something something;four

Answer 1: Provided you can uniquely identify where you want to remove the newline
Find: “(Pattern 1 at end of line)\r\n” - Replace with “\1”
Or Find: “(Pattern 1 at end of line)\r\n(Pattern 2 at start of next line)\” - Replace with “\1\2”
Answer 2: Instead if you can identify where you want to keep the newlines
Find: “(Pattern 1 at end of line)” – Replace with “\1QAZ” where “QAZ” is not anywhere in the file. Continue until "QAZ" is everywhere you require
Remove all new lines by Find “\r\n” – Replace with nothing.
Restore required new lines by Find “QAZ” – replace with “\n” – windows Notepad++ does not need the \r

Related

notepad++ remove new line in " " at my csv-file

My problem is that I have a csv-file with alot of new line. How can I remove the newlines with select and replace? My other stuff should stay how it is.
Here the example:
101080;101080;101080;104;
101098;101098;101098;105;
101099;101099;101099;106;"RING 750GG 1BRI TW VS 0,0300ct 1 RUBIN WEITE58.0
BREITE 4.5mm
72-91872-0-0 045-71-0-58-3
704.- VP1000.-
";
1011;1011;1011;106;
101093;101093;101093;123;
I have all over the csv file these new lines. I need to make that in 1 line.
thank you for the help
If I understand the question correctly, you only wish to remove the newlines for any lines that do not end in a semicolon character. You can do that below with this Find and Replace in Notepad ++ using the Regular Expression Search Mode.
Find: ([^;]$)(\r\n)
Replace: \1
Explanation of the find is that it is looking for the end of line and newline character that isn't preceded by a semicolon character. The parenthesis tell the find to group the results, which allows us in the replace to just keep the first grouping of find results and to discard the newline characters for these lines that don't end in a semicolon, which will then end up making it all line up on the previous line.
Here is a simple solution:
Activate the ShowAll Icon (¶) in the toolbar of Notepad++
Mark a ; and NewLine-Sequence (CR LF) in your file
Use the shortcut Ctrl + F
Select the Replace tab in the appeared search window
Insert ; in the Replace with text box
Press Replace All
Now all items ending with a ; are in single rows.
To remove all new lines: Just replace "\r\n" (windows) or "\n" (unix) with nothing! Using Extended or Regex options.
To just remove some:
First add unique data where you want to keep the new line - I use "QAZ".
Then remove all new lines as above.
Then replace "QAZ" with "\n".

Notepad++ tabs to spaces everywhere other than beginning of line

Due to a new coding style that I've been having to use I'm required to use tabs in the beginning of lines but spaces everywhere else to align things.
Is there a way to customize notepad++ to only replace tabs with spaces if it's not at the beginning of a new line?
Just as an example of what I mean I'll use this bit of 'code':
function someFunction():
while(true):
veryLongCodeStuff() // Some comment
shortCode() // Aligned comment
Which I would have to write like this (where \t = tab and a "." represents a space):
function someFunction():
\twhile(true):
\t\tveryLongCodeStuff()..// Some comment
\t\tshortCode()..........// Aligned comment
To convert existing files, I would suggest a two step approach:
replace all tabs with spaces (this can be done with Edit -> Blank operations -> TAB to Space )
replace spaces at the beginning of lines: do a regular expression find/replace like this:
Open Replace Dialog
Find What: ^([\t]?)( ){4} instead of 4 use the number of spaces you have configured as tab width
Replace With: \1\t
check regular expression
click Replace All: as each Replace All replaces only one indent level for all lines: repeat until the status bar of the find dialog tells you, that no more replacements were done (just keep Alt-A pressed for a second or two)

Notepad++ RexEx Remove everything between 2 html tags ( with line break between )

I want to remove in a html document with notepad++
everything between the marked area
So the Start point to remove is ( including ) "<imgCRLF" and then everything between including CRLF
and then including "DetailsCRLF</aCRLF" for the End ponint
I started simple with <img.*<a/> and ticked
and I tried to improve this starting point but always got either nothing was deleted or to much :)
Use <img.*?</a>[\r\n]*. The .* is too greedy. [\r\n]* will capture the whitespace after </a>.
Also, if you are only interested in matching <img with subsequent line breaks, you can use another regex:
<img[\r\n].*?</a>[\r\n]*

Insert same code around different filenames

I am making a small online database that is accessible through the form of checkboxes for download. I was wondering if there was some way to list all of the filenames available for download in Sublime Text 2 and insert the same code around each filename?
Everything is functional, it would just save me a lot of repetitive copy and pasting if there is a faster way to do this.
Use SublimeText Find & Replace. Click the Regex button (it looks like a * to the left of the search box)
In the Find box, insert: (^.*$)
In the replace box: [yourcode]$1[yourcode]
Where [yourcode] is what you want to insert into the box.
So, if you want to make them all <li> then your replace box would be:
<li>$1</li>
Remember to use escape \ characters where they are needed, in case you need to insert restricted characters.
^ - beginning of a new line.
. - wildcard
* - any number of the previous character in the sequence (in this case a wildcard, so any text)
$ - the end of a line
() - denotes a block, it's how the $1 knows what text to put in it's place.
Sublime Text Search and Replace
Use search/replace on a text editor with regular expressions.
^ and $ represent the beginning and end of a line - thus allowing you to easily surround each line with the appropriate text.
Sometimes you can copy the newline character (as in copy the end of one line to the beginning of the next line), and replace that with whatever text you need.
You could always use the regular expression search / replace feature in Notepad++.

<Batch> How to find a line in file and add few lines under it?

I'm trying to find a line
"<!-- here comes the new post -->"
in an HTML file and add some lines that will contain some vars and special characters like <>#"" below it, without replacing the lines that are already below, because the line
will be always in the middle of the file.
--David
You should read Remove multi-line strings from a text file using a batch script.
If you can remove lines you should be also be able to insert lines.