Jump to content

My script exits with no reason


Recommended Posts

I have a list of 64.000 words (which mostly repeat) on the B column of an Excel file, and 5.000 other words, which are the "esence" of the 64k ones, and shorter in lenght as well. So, here's my script:

#include <ExcelCOM_UDF.au3>
$oExcel =_ExcelAttach("Microsoft Excel - MyFile","Title")
WinActivate("Microsoft Excel - MyFile")

For $i = 1 to 5185 
$Find =  _ExcelReadCell($oExcel, $i, 9)
$result = StringStripWS($Find, 3)
$Choord = _ExcelFindInRange($oExcel, $result, 1, 2, 63865, 2, 0, 2, False, "")   
For $k =1 to $Choord[0][0]
_ExcelWriteCell($oExcel, $result, $Choord[$k][3], $Choord[$k][2] + 1)
Next
Next

But, when I run it, it makes some 'replacements' for a few minutes, and then stops (it search and write till about the 700th word in the 5k list). What's the problem with it?

Link to comment
Share on other sites

I ran your script and I didn't run into the same problem that you did, but then again I don't have the same data that you have I just used data I created myself to test it. The only problem that I had was that my CPU spiked to 100% usage while I was running the script, with EXCEL.EXE using on average 85-95% of the CPU at any given time. I added a sleep in the code of 250 ms and the CPU usage went down to 30-50%. Although this way will be slower you might try and see if it's just a timing issue. I also added in a couple console writes to see my progress which can be removed.

#include <ExcelCOM_UDF.au3>
$oExcel =_ExcelAttach("Microsoft Excel - MyFile.xls","Title")
WinActivate("Microsoft Excel - MyFile")

For $i = 1 to 5185 
ConsoleWrite("i = " & $i & @CRLF)
$Find =  _ExcelReadCell($oExcel, $i, 9)
$result = StringStripWS($Find, 3)
$Choord = _ExcelFindInRange($oExcel, $result, 1, 2, 63865, 2, 0, 2, False, "")   
    For $k =1 to $Choord[0][0]
        _ExcelWriteCell($oExcel, $result, $Choord[$k][3], $Choord[$k][2] + 1)
        ConsoleWrite("k = " & $k & @CRLF)
    Next
    Sleep(250)
Next
Link to comment
Share on other sites

I think it will be VERY slower, because it has to search through 64.000 lines, and repeat this 5.000 times. As it is takes a lot, plus the quarter of the second would be a very long time. But if this solves the exit problem, I think I'll let it work over night. Thanks for replying and for the progress track, it's very useful (I used to watch the left slidebar in Excel to see how much it has till the end).

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...