Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


python help

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
AverageAzn247
Grandmaster Cheater
Reputation: 34

Joined: 01 Oct 2007
Posts: 909
Location: Austin,TX with 72 virgins

PostPosted: Sat Apr 16, 2011 10:08 am    Post subject: python help Reply with quote

I am supposed to write a program that compares txt files and tells where the first different is by line and column. I am able to find it by line but how would I find it by column? use .split(" ") ?
http://www.mediafire.com/?7m4brllzzbnddzc

_________________


Waxxup wrote:
What are Night Elves?
A girl group?
Back to top
View user's profile Send private message MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sat Apr 16, 2011 3:00 pm    Post subject: Reply with quote

I don't use python but a method would be to:
1. Split each file into separate lines.
2. Compare line by line (full line compare.)
-- If matched, continue to next line.
-- If no match, step into each line letter by letter.

If python lets you do indexing on a string you can try doing that. If not, use split or substring (which ever they support) and pull 1 character at a time, increasing the position 1 by 1.

See:
http://docs.python.org/release/2.5.2/lib/string-methods.html

A method of reading char by char:
http://mail.python.org/pipermail/tutor/2006-August/048830.html

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
AverageAzn247
Grandmaster Cheater
Reputation: 34

Joined: 01 Oct 2007
Posts: 909
Location: Austin,TX with 72 virgins

PostPosted: Sun Apr 17, 2011 12:48 pm    Post subject: Reply with quote

i did break it by line but the problem is that i can't figure out how to do it character by character since i converted everything into a list rather than str
_________________


Waxxup wrote:
What are Night Elves?
A girl group?
Back to top
View user's profile Send private message MSN Messenger
AhMunRa
Grandmaster Cheater Supreme
Reputation: 27

Joined: 06 Aug 2010
Posts: 1117

PostPosted: Tue Apr 19, 2011 9:13 am    Post subject: Reply with quote

regex.match()
string.find()
string.count()

Should be what you are looking for.

If you like Python give this site a try. http://www.pythonchallenge.com/ Learned alot there.

Not quite what you are doing but may give you some ideas. Wrote this in 06
Code:

# emlremove.py
# Author   **********
# Date      27 September 2006
# Last Edit   28 September 2006
# usage: emlremove.py > <FILEIN> <NAMES TO REMOVE> <FILEOUT>
#
#   Parses a raw dump of user accounts, array line
#   Compares the dump to an array of names to remove
#   Names to remove includes past compiles and dead
#   accounts.
#   Also includes the @company domain.
#
#   MODIFICATION:
#
#   Added check on file out.
#   If no data was written to fileout,
#   File is deleted. Added confirmation screens.

def remove( firstArg, secondArg, thirdArg ):
   import re, string, os
   
   # OPEN OUR FILES FOR READING AND/OR WRITING
   filea = open(firstArg, 'r')
   fileb = open(secondArg, 'r')
   filec = open(thirdArg, 'w')

   # SANITY CHECK
   success = ""
   # MOVE CONTENTS OF FILES INTO A LIST PLACEHOLDER
   line = filea.readlines()
   names = fileb.readlines()
   # SANITY CHECK
   matches = ""
   # CHECK FOR WETHER OR NOT WE ACTUALLY WROTE DATA TO filec
   didWeWrite = "FALSE"
   for l in line:
      # STRIP THE NEWLINE CHAR FROM EACH ELEMENT OF OUR LIST
      # WE DO THIS BECAUSE A NEWLINE IS READ IN BY readlines()
      l = string.replace(l, "\n", "")
      for n in names:
         # AGAIN WITH THE STRIPPING
         n = string.replace(n, "\n", "")
         # IF ELEMENT l IS EQUAL TO ELEMENT n WE HAVE A MATCH
         if l == n:
            matches = "TRUE"
         elif matches == "TRUE":
            # IF WE MATCH SANITY CHECK SHOULD NOT PASS
            success = "FALSE"
         else:
            # IF WE ARE NOT EQUAL SANITY CHECK SHOULD PASS
            if l != n:
               success = "TRUE"
            else:
               success = "FALSE"
      # IF WE ARE SANE LET'S PRINT OUT OUR LIST AND APPEND THE DOMAIN ADDRESS
      if success == "TRUE":
         didWeWrite = "TRUE"
         if l != "uyser":
            filec.write(l + "@domain.com\n")
      else:
         pass
      # RESETTING OUR SANITY CHECKS
      success = ""
      matches = ""
   # TIDY UP OPEN FILES
   filea.close()
   fileb.close()
   filec.close()
   # DELETE UNEEDED FILE (WHICH IS OUR INFILE)
   #os.remove(firstArg)
   # DID WE WRITE CHECK
   if didWeWrite == "FALSE":
      print '''\n--------------------\n\n
NO NEW NAMES TO ADD\n\n
--------------------'''
      os.remove(thirdArg)
   else:
      print '''\n--------------------\n\n
NEW USERS FOUND...
   WRITING DATA TO...
         .... %s ....\n\n
--------------------''' % thirdArg

# OUR MAIN ENTRY POINT
if __name__ == "__main__":
   import sys
   # IF INCORRECT NUMBER OF ARGS USED WE SHOW USAGE SCREEN
   if len(sys.argv) != 4:
      print '''\n********************\n\n
NAME:   emlremove.py
AUTHOR: *********
DATE:   27 September 2006\n
Usage suggestion:\n
emlremove.py arg1 arg2 arg3\n
\n
For example:\n
C:\Python24\emlremove.py <READ FILE IN> <NAMES TO REMOVE> <SAVE TO>\n
********************'''
   # IF CORRECT NUMBER OF ARGS USED WE RUN
       else:
      remove(sys.argv[1], sys.argv[2], sys.argv[3])

_________________
<Wiccaan> Bah that was supposed to say 'not saying its dead' lol. Fixing >.>
Back to top
View user's profile Send private message
AverageAzn247
Grandmaster Cheater
Reputation: 34

Joined: 01 Oct 2007
Posts: 909
Location: Austin,TX with 72 virgins

PostPosted: Tue Apr 19, 2011 9:29 pm    Post subject: Reply with quote

i figured it out. Turns out i have to store it into a new list for the characters.
_________________


Waxxup wrote:
What are Night Elves?
A girl group?
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites