AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Selecting in a txt database

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Leonidas225



Joined: 30 Jan 2009
Posts: 12

PostPosted: Fri Mar 27, 2009 10:38 pm    Post subject: Selecting in a txt database Reply with quote

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
View user's profile Send private message
Guest






PostPosted: Fri Mar 27, 2009 11:14 pm    Post subject: Reply with quote

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

PostPosted: Fri Mar 27, 2009 11:53 pm    Post subject: Reply with quote

Quote:
This would be MUCH easier in python...


any other "useful" suggestion?
Back to top
View user's profile Send private message
jaco0646



Joined: 07 Oct 2006
Posts: 3113
Location: MN, USA

PostPosted: Fri Mar 27, 2009 11:55 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Leonidas225



Joined: 30 Jan 2009
Posts: 12

PostPosted: Sat Mar 28, 2009 12:27 am    Post subject: Reply with quote

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
View user's profile Send private message
jaco0646



Joined: 07 Oct 2006
Posts: 3113
Location: MN, USA

PostPosted: Sat Mar 28, 2009 1:00 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Leonidas225



Joined: 30 Jan 2009
Posts: 12

PostPosted: Sat Mar 28, 2009 1:06 am    Post subject: Reply with quote

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
View user's profile Send private message
Guest






PostPosted: Fri Apr 24, 2009 6:09 pm    Post subject: Reply with quote

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
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group