Thread: Analyzing files

Page 2 of 2 First 12
  • Jump to page:
    #16
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2005
    Location
    Raleigh NC
    Posts
    89
    Rep Power
    10
    well here is the latest of what i have created, yes i realize that the loop is screwed up but im at a loss in a pathetic mental block of how to rearrange it better
    Code:
    import os
    print """ Please Enter The Filename/Location
    Of A File To Open."""
    text_file1 = raw_input(': ')
    f = open(text_file1, 'r')
    
    SVN1 = raw_input("Enter Your Previous SVN: ")
    SVN2 = raw_input("Enter Your Current SVN: ")
    
    if SVN1 == SVN2:
    	print "Congradulations Your Software Is Up-To Date."
    
    elif SVN2 > SVN1:
    	while (True):
    		line = f.readline()
    		if len(line) < 1:
    			break
    		else:
    			print 'ZZZ', line
    			DATA1 = line.split('\s')
    			#print 'YYY', DATA1
    			DATA2 = line.split('\t')
    			#print 'XXX', DATA2
    			choice1 = raw_input  ("Do You Wish To Export The Data, Y/N: ")
    			if choice1 == "Y" or choice1 == "y":
    				print ("Now Preparing Data To Be Exported...")
    				file_name1 = raw_input ("Enter Desired Filename & Extension: ")
    				text_file2 = open(file_name1, "w")
    				text_file2.write ('SVN1 = ' + SVN1 + '\n')
    				text_file2.write ('SVN2 = ' + SVN2 + '\n')
    				text_file2.writelines(DATA1)
    				text_file2.close()
    				print ("Data Export Successful" )
    			elif choice1 == "N" or choice1 == "n":
    				print ("Data Export Canceled")
    				raw_input ("\n\nPress the enter key to exit.")
    				break
    			else :
    				print ("Choice Not Recognized")
    				raw_input ("\n\nPress the enter key to exit.")
    				break
    
    
    elif SVN2 < SVN1:
    	print """
    		You Entered A Number That Is Older Than
    		Your First Number. Please Try Again."""
    	raw_input ("\n\nPress the enter key to exit.")
    any suggestions about the loop thing.
  2. #17
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    As promised here is my example, this simply illustrates reading the dictionary from the file and writing it back after making some changes .

    Take care,

    Mark.
    Attached Files
    programming language development: www.netytan.com Hula

  4. #18
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2005
    Location
    Raleigh NC
    Posts
    89
    Rep Power
    10
    gracias... reading the code now...
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo