I am trying to remove commas inside double quotes from a csv file in notepad++, this is what I have:
1070,17,2,GN3-670,"COLLAR B, M STAY","2,606.45"
and I need this:
1070,17,2,GN3-670,"COLLAR B M STAY","2606.45"
I ma trying to use notepad find/replace option with a reg exp. pattern. I tried all kind of combination but didn't manage to do :( The file contains 1 million rows.
After whole today I am not anymore sure if a simple regex can do? Maybe I should go with a script...python?
To remove all commas from a string, call the replace() method, passing it a regular expression to match all commas as the first parameter and an empty string as the second parameter. The replace method will return a new string with all of the commas removed.
If you find any unnecessary commas in data then you can get them removed, owing to various functions, like TRIM, SUBSTITUTE, FIND, LEN, REPLACE or you can use FIND & REPLACE (CTRL + H). You can choose from several methods to remove them.
The easiest way to do this is to highlight one of the quotes, then select Search, then Replace. You will see the Find What field is already filled in with the quote you selected. I suggest have Search mode set to normal. Make sure the Replace With field is empty.
Firstly, double quote character is nothing special in regex - it's just another character, so it doesn't need escaping from the perspective of regex. However, because Java uses double quotes to delimit String constants, if you want to create a string in Java with a double quote in it, you must escape them.
Try the following
import re
print re.sub(',(?=[^"]*"[^"]*(?:"[^"]*"[^"]*)*$)',"",string)
This will remove comma between quotes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With