Jindon - I like this approach, much better/faster to process as a text file; however I think your RegEx pattern is incorrect, this leaves lines where
NA is only in the last column i.e. there is no trailing comma. the pattern
"^.*NA,.*?\r\n|^.*,NA\r\n" would remove all occurrences of
NA including those only in the last column.
this approach also got me thinking about how else to achieve the goal, as this is a CSV file, parsing as text at the command line is likely the most efficient way; Jindon's code effectively does this, just from within Excel.
if you're on a Unix machine (Linux or OS X) then you can use
SED (stream editor) from the terminal. this processes the changes in under a second!
sed '/NA/d' ahs-comb-madhya_pradesh-dhar.csv > ahs-comb-madhya_pradesh-dhar_CLEAN.csv
I believe you could use PowerShell on Windows to do something similar but am not very familiar with it, the below command appears to work, although takes about 7 seconds, so not as fast as Jindon's code.
Get-Content .\ahs-comb-madhya_pradesh-dhar.csv | Where-Object {$_ -CNotMatch 'NA'} | Set-Content ahs-comb-madhya_pradesh-dhar_CLEAN.csv
Bookmarks