Jump to content

Fileread problems


malu05
 Share

Recommended Posts

Im trying to read from a CSV file.

I need to find a ID (defined in the first field)

So i do a split for the newline + ID

StringSplit($FILEATr,@lf&"60",1)

54,"","",550,64,0,11,35,1,0,8,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0
55,"","",156,64,0,11,35,13,61,0,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0
56,"","",157,64,0,11,35,1,303,0,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0
57,"","",158,64,0,11,35,1,0,5,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0
59,"","",159,1048640,0,11,35,1,0,0,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0
60,"","",606,64,0,11,35,1,0,8,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0
61,"","",160,64,0,11,35,1,0,0,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0
62,"","",161,64,0,11,35,1,0,8,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0
63,"","",162,64,0,11,35,1,0,6,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0

Now the funny part is if I put StringSplit($FILEATr,@lf&"6",1) it will put the ID 60 in the first instance of the array.

But if i put StringSplit($FILEATr,@lf&"60",1) it returns nothing.

Why is this so?

[center][u]WoW Machinima Tool[/u] (Tool for Machinima Artists) [/center]

Link to comment
Share on other sites

I'm just getting more and more confused as I'm trying to understand heh, I think the approach you chose isn't belong here... Are you trying to find the first occurrence of @LF & '60' as exact match to split this long string into two separated strings or it's just one occurrence of many in the CSV file?

Edited by Authenticity
Link to comment
Share on other sites

I'm just getting more and more confused as I'm trying to understand heh, I think the approach you chose isn't belong here... Are you trying to find the first occurrence of @LF & '60' as exact match to split this long string into two separated strings or it's just one occurrence of many in the CSV file?

Hehe, i can see.. well i want to split the string at "60,"

But since there might be some ID's with 60 in the end i added @LF to ensure that we get the 6 at the beginning at the line.

So what i want to do is do a split at @LF & "60,"

But as stated in the first post, doing a split at @LF & "60," returns "nothing" as if it was not found.

[center][u]WoW Machinima Tool[/u] (Tool for Machinima Artists) [/center]

Link to comment
Share on other sites

Im trying to read from a CSV file.

I need to find a ID (defined in the first field)

So i do a split for the newline + ID

StringSplit($FILEATr,@lf&"60",1)

54,"","",550,64,0,11,35,1,0,8,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0
55,"","",156,64,0,11,35,13,61,0,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0
56,"","",157,64,0,11,35,1,303,0,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0
57,"","",158,64,0,11,35,1,0,5,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0
59,"","",159,1048640,0,11,35,1,0,0,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0
60,"","",606,64,0,11,35,1,0,8,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0
61,"","",160,64,0,11,35,1,0,0,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0
62,"","",161,64,0,11,35,1,0,8,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0
63,"","",162,64,0,11,35,1,0,6,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0

Now the funny part is if I put StringSplit($FILEATr,@lf&"6",1) it will put the ID 60 in the first instance of the array.

But if i put StringSplit($FILEATr,@lf&"60",1) it returns nothing.

Why is this so?

They both work exactly as advertised:
#include <Array.au3>

$sData = '54,"","",550,64,0,11,35,1,0,8,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0' & @CRLF & _
'55,"","",156,64,0,11,35,13,61,0,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0' & @CRLF & _
'56,"","",157,64,0,11,35,1,303,0,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0' & @CRLF & _
'57,"","",158,64,0,11,35,1,0,5,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0' & @CRLF & _
'59,"","",159,1048640,0,11,35,1,0,0,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0' & @CRLF & _
'60,"","",606,64,0,11,35,1,0,8,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0' & @CRLF & _
'61,"","",160,64,0,11,35,1,0,0,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0' & @CRLF & _
'62,"","",161,64,0,11,35,1,0,8,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0' & @CRLF & _
'63,"","",162,64,0,11,35,1,0,6,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0'

$avData = StringSplit($sData, @LF & "6", 1)
_ArrayDisplay($avData, "$avData")

$avData = StringSplit($sData, @LF & "60", 1)
_ArrayDisplay($avData, "$avData")

But this method will probably work better for you:

#include <Array.au3>

$sData = '54,"","",550,64,0,11,35,1,0,8,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0' & @CRLF & _
'55,"","",156,64,0,11,35,13,61,0,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0' & @CRLF & _
'56,"","",157,64,0,11,35,1,303,0,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0' & @CRLF & _
'57,"","",158,64,0,11,35,1,0,5,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0' & @CRLF & _
'59,"","",159,1048640,0,11,35,1,0,0,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0' & @CRLF & _
'60,"","",606,64,0,11,35,1,0,8,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0' & @CRLF & _
'61,"","",160,64,0,11,35,1,0,0,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0' & @CRLF & _
'62,"","",161,64,0,11,35,1,0,8,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0' & @CRLF & _
'63,"","",162,64,0,11,35,1,0,6,"",0,0,0,0,0,0,0,"000000000000000000000000",0,0,0,0,0,0,0,16712190,0,0,0,0,0,3287941120,0,0'

$avData = StringSplit($sData, @CRLF, 1)
_ArrayDisplay($avData, "$avData")

$sSearch = "60"
$sRecord = ""
For $n = 1 to $avData[0]
    If StringLeft($avData[$n], StringLen($sSearch)) = $sSearch Then
        $sRecord = $avData[$n]
        ExitLoop
    EndIf
Next

MsgBox(64, "Record", $sRecord)

:)

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