| View previous topic :: View next topic |
| Author |
Message |
Leonidas225
Joined: 30 Jan 2009 Posts: 12
|
Posted: Fri Mar 27, 2009 10:38 pm Post subject: Selecting in a txt database |
|
|
| Code: | List=
(
75313271 TRUE $55
75472340 FALSE $70
25403501 FALSE $55
35452076 TRUE $42
95703195 FALSE $70
85353158 FALSE $42
35452076 TRUE $42
35803125 FALSE $55
25433191 FALSE $42
)
;I wanna select the first ID if the 2nd column FALSE and the 3th $55 OR $42
Loop, Parse, List,`n
{
row:=A_LoopField
loop, parse, row, %A_Tab%
{
if (A_Index = 1)
firstField := A_LoopField
if (A_Index = 2 && A_LoopField != "FALSE")
break
if (A_Index = 3 && (A_LoopField != "$55" OR A_LoopField != "$42" ))
break
IDList .= firstField "`n"
}
}
Msgbox %IDList% |
If you have a simplier or better approach then feel free to post. |
|
| Back to top |
|
 |
Guest
|
Posted: Fri Mar 27, 2009 11:14 pm Post subject: |
|
|
This would be MUCH easier in python...
| Code: |
idlist = []
for line in open("textdata.txt","r"):
if str(line.split()[1]) == 'FALSE':
if str(line.split()[2]) == '$55': idlist.append(line.split()[0])
if str(line.split()[2]) == '$42': idlist.append(line.split()[0])
print idlist
|
That was just a quick and dirty approach, im sure it could be done even more efficiently |
|
| Back to top |
|
 |
Leonidas225
Joined: 30 Jan 2009 Posts: 12
|
Posted: Fri Mar 27, 2009 11:53 pm Post subject: |
|
|
| Quote: | | This would be MUCH easier in python... |
any other "useful" suggestion? |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 3113 Location: MN, USA
|
Posted: Fri Mar 27, 2009 11:55 pm Post subject: |
|
|
| I'm not quite clear on what you want. What is the expected output of the message box? It should narrow the list down to one number and one dollar amount? |
|
| Back to top |
|
 |
Leonidas225
Joined: 30 Jan 2009 Posts: 12
|
Posted: Sat Mar 28, 2009 12:27 am Post subject: |
|
|
the expected output of the message box:
25403501
85353158
35803125
25433191
A list of only the ID's where
the 2nd column = "TRUE" AND (the 3rd coulomn =$55 OR $42) |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 3113 Location: MN, USA
|
Posted: Sat Mar 28, 2009 1:00 am Post subject: |
|
|
I think you meant 2nd column = "FALSE" (those are the numbers you listed). | Code: | Loop, Parse, list,`n
{
StringSplit, list, A_LoopField, %A_Tab%
If (list2 = "FALSE") AND (list3 = "$55" OR list3 = "$42")
IDList .= list1 "`n"
}
Msgbox, %IDList% |
|
|
| Back to top |
|
 |
Leonidas225
Joined: 30 Jan 2009 Posts: 12
|
Posted: Sat Mar 28, 2009 1:06 am Post subject: |
|
|
| jaco0646 wrote: | | I think you meant 2nd column = "FALSE" (those are the numbers you listed) |
yeah of course. my mistake. ty it works fine!! |
|
| Back to top |
|
 |
Guest
|
Posted: Fri Apr 24, 2009 6:09 pm Post subject: |
|
|
| Leonidas225 wrote: | | Quote: | | This would be MUCH easier in python... |
any other "useful" suggestion? |
LOL, so python, a much faster and robust scripting language, especially for manipulating text is not "useful"? That script does exactly what you want in a fraction of the time it would take AHK to do it.
Guess it just goes to show how some people go through life with blinders on. |
|
| Back to top |
|
 |
|