Jump to content
Sign in to follow this  
aslani

Deleting Lines

Recommended Posts

aslani

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:

Line#,PartNumber,,OldRev,NewRev,Type,Description,,,,,,Date,,,

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;

NumberOfSplits
Line#
PartNumber

OldRev
NewRev
Type
Description





Date

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? :)


[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Share this post


Link to post
Share on other sites
PsaltyDS

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)
Next
$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
aslani

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
Next

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

The tmp.txt will have the cleaned version?

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

Edited by aslani

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.