Jump to content
Sign in to follow this  

Deleting Lines

Recommended Posts

I've been searching the forums for 2 days now and I can't seem to find what I'm looking for. So here's my problem.

I have a spreadsheet in Excel that looks like this:


After converting it to comma delimited .csv file.

Now my script opens that file and run StringSplit() and save it into a temporary .txt file. It is now looks like this;




I'm trying to get rid of the blank lines and I can't seems to find the right script to do it. I know it can't be that complicated, I might just be overlooking something.

Any advice? :)

Share this post

Link to post
Share on other sites

After the StringSplit() do this to clean out empty lines in the resulting array:

For $n = Ubound($YourArray) - 1 To 1 Step -1
      If StringStripWS($YourArray[$n], 8) = "" Then _ArrayDelete($YourArray, $n)
$YourArray[0] = Ubound($YourArray) - 1

_ArrayDelete() is in the array.au3 UDF


Edit: Forgot the "Step -1"

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post

Link to post
Share on other sites

Thanks for the fast reply. :)

Here's a follow up question.

Is the cleaned array saved into $YourArray?

So if I do something like;

$datas = ""
For $element In $YourArray
$datas = $datas & $element & @CRLF

$file = FileOpen(@ScriptDir & "\ecotmp.txt", 2)
FileWrite(@ScriptDir & "\tmp.txt", "" & $datas)

The tmp.txt will have the cleaned version?

EDIT: Ok, nvm. It works. tyty :)

Edited by aslani

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...