Programming

#30 Text/CSV file – Delete lines based on a value


Reading Time: 1 minute

I made a PowerShell script that scanned multiples subnets and generated about 130,000 lines of text. About 120,000 of these lines were not needed. Because the output was a CSV file, it was logical that I use Excel to delete these lines. But the macro that I used took forever and after one hour, it just stopped working. CSV is a text file, so I used Notepad++ to edit the file.

In order to delete the whole line that contained “NO RESPONSE” (in my case), I used Edit | Replace or Ctrl-H.

This replacement will delete all lines that contain the string “NO RESPONSE”. The syntax is ^.*YOUR_STRING.*$ and do not put nothing for “Replace with:” value. Make sure “Regular expression” is selected. The only problem is that these lines will be gone, but you’ll have empty lines now. In order to get rid of these lines, head to TextFX home page at SourceForge. Download this Notepad++ plugin, unzip the archive and put the DLL under C:\Program Files\Notepad++\plugins folder. Once you restart Notepad++, you’ll see a new menu called…TextFX. Select everything (Ctrl-A), then TextFX | TextFX Edit | Delete blank lines.

Programming
#12 Passing variables by reference between two forms in Visual C++
Programming
#43 Run PowerShell script as a scheduled task that uses Excel COM object
FreeBSD
#78 Install Ruby/Tk on Windows 10, FreeBSD and CentOS
There are currently no comments.