Jump to content

Need help with this string


Shinies
 Share

Recommended Posts

Hey, iv been trying to get this to work for ages now, and i cant see why it wont. Heres the contents the

text file it scans through. It scans fine, it seems to get the first second and third correctly, but on the last one it doesnt work, it should be: If $Linesplit[3] > "7,000,000" And $Linesplit[4] < "700" but it writes ones with like 1265 and much over 700 to the txt file.

504,450|GDB666|7,043,212|1265
504,450|GDB666|1,043,212|150
504,450|GDB666|2,043,212|1265
504,450|GDB666|4,043,212|2000
504,450|GDB666|10,043,212|400

And here is the script:

$File2 = FileOpen("C:\WINDOWS\Desktop\123.txt", 0)
$Size = _FileCountLines( "C:\WINDOWS\Desktop\123.txt" )
For $a = 1 To $Size
    $Line = FileReadLine( $File2, $a )
    $LineSplit = StringSplit($Line, '|')
    If $LineSplit[3] > "7,000,000" And $LineSplit[4] < "700" Then
        FileWrite( "Results.txt", $LineSplit[2] & " " & $LineSplit[3] & "   " & $LineSplit[4] & @CRLF )
    EndIf
Next
FileClose($File2)
Link to comment
Share on other sites

  • Moderators

I had to use Beta... Kind of a bugger really.

#include <file.au3>
#include <string.au3>

$File2 = FileOpen(@DesktopDir & "\123.txt", 0)
$Size = _FileCountLines( @DesktopDir & "\123.txt" )
For $a = 1 To $Size
    $Line = FileReadLine( $File2, $a )
    $LineSplit = StringSplit($Line, '|')
    If Number(StringRegExpReplace($LineSplit[3], ",", "")) >= '7000000' And Number($LineSplit[4]) <= "700" Then
        FileWrite( "Results.txt", $LineSplit[2] & " " & $LineSplit[3] & "   " & $LineSplit[4] & @CRLF )
    EndIf
Next
FileClose($File2)

Hope this helps :P

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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...