Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Add lines to main line, until next main line?

$
0
0
I have a file that was pulled from an excel sheet - CVS. I need to add all the lines between the first all lines until the next format - I know clear as mud!

Each main line begins with the following format - 2 letters (abbr of the US State), followed by 3 numbers - the part of the US State.

So Maryland would be MD, and Rockville would be 123 - total format MD123 - I need all the lines including this line, until I reach the next location MD124.

The Excel file was chopped up really good, nothing I have done so far has worked...what I am hoping to do is to grab all the lines between the two locations - some lines include everything needed in the line and some lines have 3-5 lines between locations. - but I need it to be all one line, so that I can grab the info from that line and search it - I do not think the following code is even a good starting point, but this is what I have tried, plus many more - I am at a loss, as I have been trying to do this for two days.

Any help or additional info needed - thanks for your time.

[ autoit ]         
While 1 And $countIT <> 25   $NewLineNumber = 0   $countIT += 1   $line = FileReadLine($File, $iLineNumber) ; read the first line, and continue until end   If @error = -1 Then    ;MsgBox('','End of File',$Device & ' Line=' & $iLineNumber)    ExitLoop   EndIf   If $line = '' Then    $iLineNumber += 1    ContinueLoop   Else    Do     $sLetters_2 = StringLeft($line, 2)     $sNumbers_3 = StringMid($line, 3, 3)     ;     $sNumbers_3 = Number($sNumbers_3)     ;     ConsoleWrite('--> EXISTING LINE ' & $sLetters_2 & $sNumbers_3 & @CRLF)     ;     If (IsString($sLetters_2) = True And StringLen($sLetters_2) = 2) And (IsNumber($sNumbers_3) = True And StringLen($sNumbers_3) = 3) Then      $AddLine = True     Else      ConsoleWrite($line & ' -->> does not meet requirement ' & $sLetters_2 & $sNumbers_3 & @CRLF)      #cs             MsgBox('', '', 'Is String = ' & IsString($sLetters_2) _       & @CRLF & 'StringLen($sLetters_2) ' & StringLen($sLetters_2) & ' <> 2' _       & @CRLF & 'IsNumber($sNumbers_3) ' & IsNumber($sNumbers_3) _       & @CRLF & 'StringLen($sNumbers_3) ' & StringLen($sNumbers_3) & ' <> 3')      #ce      $NewLineNumber += 1      $sTempLine = FileReadLine($File, $iLineNumber + $NewLineNumber)      If @error = -1 Then       ;MsgBox('','End of File',$Device & ' Line=' & $iLineNumber)       ExitLoop 2      EndIf      ConsoleWrite('TempLINE ' & $sTempLine & @CRLF)      $line &= $sTempLine      ConsoleWrite('LINE ' & $line & @CRLF)     EndIf    Until $AddLine    $iLineNumber += $NewLineNumber   EndIf   ConsoleWrite('1 need to search on this line ' & $line & @CRLF)   WEnd If $sLocation = '' Then MsgBox('', 'Not Found', 'Location was not found for device ', 1) FileClose($File)

edit forgot to end my tag

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>