<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://performiq.com/kb/index.php?action=history&amp;feed=atom&amp;title=Readfile.py</id>
	<title>Readfile.py - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://performiq.com/kb/index.php?action=history&amp;feed=atom&amp;title=Readfile.py"/>
	<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Readfile.py&amp;action=history"/>
	<updated>2026-05-20T21:40:45Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>https://performiq.com/kb/index.php?title=Readfile.py&amp;diff=3100&amp;oldid=prev</id>
		<title>PeterHarding at 06:09, 19 July 2009</title>
		<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Readfile.py&amp;diff=3100&amp;oldid=prev"/>
		<updated>2009-07-19T06:09:51Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:09, 19 July 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l119&quot;&gt;Line 119:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 119:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Python]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Python]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Examples]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>PeterHarding</name></author>
	</entry>
	<entry>
		<id>https://performiq.com/kb/index.php?title=Readfile.py&amp;diff=1482&amp;oldid=prev</id>
		<title>PeterHarding at 04:05, 25 February 2008</title>
		<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Readfile.py&amp;diff=1482&amp;oldid=prev"/>
		<updated>2008-02-25T04:05:08Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 14:05, 25 February 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l117&quot;&gt;Line 117:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 117:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;quot;&amp;quot;&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;quot;&amp;quot;&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Python]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>PeterHarding</name></author>
	</entry>
	<entry>
		<id>https://performiq.com/kb/index.php?title=Readfile.py&amp;diff=1481&amp;oldid=prev</id>
		<title>PeterHarding: New page: =Overview=  Skeleton Python script which demonstrates reading a file - implemented using getopt() in a main() function and other niceties...  ==Script==  &lt;pre&gt; #! /usr/bin/env python # #  ...</title>
		<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Readfile.py&amp;diff=1481&amp;oldid=prev"/>
		<updated>2008-02-25T04:04:53Z</updated>

		<summary type="html">&lt;p&gt;New page: =Overview=  Skeleton Python script which demonstrates reading a file - implemented using getopt() in a main() function and other niceties...  ==Script==  &amp;lt;pre&amp;gt; #! /usr/bin/env python # #  ...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=Overview=&lt;br /&gt;
&lt;br /&gt;
Skeleton Python script which demonstrates reading a file - implemented using getopt() in a main() function and other niceties...&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#! /usr/bin/env python&lt;br /&gt;
#&lt;br /&gt;
#  Purpose: read a file&lt;br /&gt;
#&lt;br /&gt;
#  Copyright (C) Peter Harding, 2003&lt;br /&gt;
#                All rights reserved&lt;br /&gt;
#&lt;br /&gt;
#  $Id:$&lt;br /&gt;
#&lt;br /&gt;
#---------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
import os&lt;br /&gt;
import sys&lt;br /&gt;
import getopt&lt;br /&gt;
&lt;br /&gt;
#---------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
__version__ = &amp;quot;1.0.0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
debugFlg    = 0&lt;br /&gt;
verboseFlg  = 0&lt;br /&gt;
filename    = &amp;quot;file.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#---------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
def rebuild(filename):&lt;br /&gt;
   try:&lt;br /&gt;
      f = open(filename, &amp;#039;r&amp;#039;)&lt;br /&gt;
   except IOError, msg:&lt;br /&gt;
      sys.stderr.write(filename + &amp;#039;: cannot open: &amp;#039; + `msg` + &amp;#039;\n&amp;#039;)&lt;br /&gt;
      sys.exit(1)&lt;br /&gt;
&lt;br /&gt;
   lineno = 0&lt;br /&gt;
&lt;br /&gt;
   while 1:&lt;br /&gt;
      line = f.readline()&lt;br /&gt;
&lt;br /&gt;
      if not line: break&lt;br /&gt;
&lt;br /&gt;
      lineno += 1&lt;br /&gt;
&lt;br /&gt;
   f.close()&lt;br /&gt;
&lt;br /&gt;
   print lineno&lt;br /&gt;
&lt;br /&gt;
#---------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
def main():&lt;br /&gt;
   global debugFlg&lt;br /&gt;
   global verboseFlg&lt;br /&gt;
&lt;br /&gt;
   try:&lt;br /&gt;
      opts, args = getopt.getopt(sys.argv[1:], &amp;quot;dvV?&amp;quot;)&lt;br /&gt;
   except getopt.error, msg:&lt;br /&gt;
      print __doc__&lt;br /&gt;
      return 1&lt;br /&gt;
&lt;br /&gt;
   for o, a in opts:&lt;br /&gt;
      if o == &amp;#039;-d&amp;#039;:&lt;br /&gt;
         debugFlg = 1&lt;br /&gt;
      elif o == &amp;#039;-v&amp;#039;:&lt;br /&gt;
         verboseFlg = 1&lt;br /&gt;
      elif o == &amp;#039;-V&amp;#039;:&lt;br /&gt;
         print &amp;quot;Version: %s&amp;quot; % __version__&lt;br /&gt;
         return 1&lt;br /&gt;
      elif o == &amp;#039;-?&amp;#039;:&lt;br /&gt;
         print __doc__&lt;br /&gt;
         return 1&lt;br /&gt;
&lt;br /&gt;
   if (debugFlg):&lt;br /&gt;
      print &amp;quot;&amp;gt;&amp;gt; Flg    %s&amp;quot; % debugFlg&lt;br /&gt;
&lt;br /&gt;
   if args:&lt;br /&gt;
      for arg in args:&lt;br /&gt;
         print arg&lt;br /&gt;
   else:&lt;br /&gt;
      pass&lt;br /&gt;
&lt;br /&gt;
   wrk = os.getcwd()&lt;br /&gt;
&lt;br /&gt;
   base = os.path.basename(wrk)&lt;br /&gt;
&lt;br /&gt;
   print wrk, base&lt;br /&gt;
&lt;br /&gt;
   return 1&lt;br /&gt;
&lt;br /&gt;
   rebuild()&lt;br /&gt;
&lt;br /&gt;
#---------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;#039;__main__&amp;#039; or __name__ == sys.argv[0]:&lt;br /&gt;
   sys.exit(main())&lt;br /&gt;
&lt;br /&gt;
#---------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
Revision History:&lt;br /&gt;
&lt;br /&gt;
     Date     Who   Description&lt;br /&gt;
   --------   ---   --------------------------------------------------&lt;br /&gt;
   20030920   plh   Initial implementation&lt;br /&gt;
   20031002   plh   Cleaned up args in main().  Added &amp;#039;-h&amp;#039;, &amp;#039;-?&amp;#039;, &amp;#039;-V&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Problems to fix:&lt;br /&gt;
&lt;br /&gt;
To Do:&lt;br /&gt;
&lt;br /&gt;
Issues:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>PeterHarding</name></author>
	</entry>
</feed>