I imagine that if you are working with a csv file, lines with empty records will not be completely blank(empty) unless the delimiter is a tab or a white space of some sort. At least those empty records will contain only the delimiter such as commas, semi-colons or pipes…etc
I have just put together a VBScript for you. Please modify the pattern with the delimiter in your csv file. In the below example, the delimiter is comma:
dim objFSO, objInputFile, objOutputFile, objRegEx
dim myCSV, strNewLineContent, strLine
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
set objRegEx = new RegExp
objRegEx.pattern =“[^,]{1,}”
myCSV = Watch.GetJobFileName
set objInputFile = objFSO.OpenTextFile(myCSV, 1, true, 0)
strNewLineContent = “”
Do Until objInputFile.AtEndOfStream
strLine = objInputFile.Readline
strLine = Trim(strLine)
If objRegEx.test(strLine)Then
strNewLineContent = strNewLineContent & strLine & vbCrLf
End If
Loop
objInputFile.Close
set objOutputFile = objFSO.OpenTextFile(myCSV, 2, true, 0)
objOutputFile.Write strNewLineContent
objOutputFile.Close
In debug mode, just before hitting the script, if I click on View as Text, you can see that my data file does contain some empty records
Once I get passed the above script, the lines containing the empty records are removed:
You can send the use the Send To Folder to save the file with %O.csv.