[Tutor] Difficulty with file.writelines()

Bryce Embry bryce@bembry.org
Fri, 24 May 2002 12:50:04 -0500


--=====================_363902874==_.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed

Howdy,

It looks like your problem stems from the difference in opening a file in 
"write" mode and opening a file in "append" mode.  By default, write mode 
will automatically overwrite any text currently in the file whenever you 
write to the file.  This works fine in your code when the desired text is 
already there, since it just writes the text in again.  But when the text 
is not already there, you do not have the program write all the text 
again.  It just overwrites everything currently in the file with the text 
you desired.

You could fix this by using "append" mode when you open the file, so that 
the line read:
         tempfile = open(os.path.join(fxdir, 'temp.fxf'), 'a')
(changed the "w" for an "a").  Or you could just change the code so it 
writes the whole text in when the matchlist is empty.

Here's one way to that might work.  I haven't tested it, but maybe it will 
help:

---
<revised code>

import re, os, os.path



def move_empty(fxf_filename, fxdir=r'C:\Dev\Tron\BUILD\Game\ClientFX'):

             fxfilepath = os.path.join(fxdir, fxf_filename)

             fxfile = open(fxfilepath, 'r')

             fxfile.seek(0)

             empty = re.compile("GroupName:.*_empty")

             matchlist = []

             matchcount = 0

             tempfile = open(os.path.join(fxdir, 'temp.fxf'), 'w')

             fxfile_text = fxfile.readlines()

             for line in fxfile_text:

                         if empty.search(line):

                                     matchlist.append(line)

                                     print matchlist

                                     matchcount = 2

                         elif matchcount > 0:

                                     matchlist.append(line)

                                     matchcount = matchcount - 1

                                     print matchlist, matchcount

                         else: tempfile.writelines(line)

             if matchlist != []:

                         for line in matchlist:

                                     tempfile.writelines(line)

                                     print line

             else:   # figure out why this is erasing everything else and 
writing

                 # only the empty_group.

                         filename = fxf_filename.split('.')

                         name = filename[0].upper()

                         empty_group = fxfile_text

                         empty_group_addition = '''\tGroupName: 
%s_empty\n\tFxInGroup: 0\n\tPhase: 10000\n'''%(name)

                         empty_group.append(empty_group_addition)

                         tempfile.writelines(empty_group)

             tempfile.close()
</revised code>


Hope that helps,
Bryce

At 12:00 PM 5/24/2002, you wrote:

>
>
>Hello everyone..   I'm attempting to see if a file has a particular group 
>of lines, and move them to the end.  If the file doesn't have this group, 
>I'd like to add a basic version of that group to the end anyways.  The 
>problem I'm having is when the file doesn't have the group of lines I'm 
>looking for.  It seems that my file.writelines() down at the end of the 
>function in the last else: block is overwriting the whole file with the 
>little group.  What Am I missing?
>
>
>
>###--------------------------###
>
>import re, os, os.path
>
>
>
>def move_empty(fxf_filename, fxdir=r'C:\Dev\Tron\BUILD\Game\ClientFX'):
>
>             fxfilepath = os.path.join(fxdir, fxf_filename)
>
>             fxfile = open(fxfilepath, 'r')
>
>             fxfile.seek(0)
>
>             empty = re.compile("GroupName:.*_empty")
>
>             matchlist = []
>
>             matchcount = 0
>
>             tempfile = open(os.path.join(fxdir, 'temp.fxf'), 'w')
>
>             for line in fxfile.readlines():
>
>                         if empty.search(line):
>
>                                     matchlist.append(line)
>
>                                     print matchlist
>
>                                     matchcount = 2
>
>                         elif matchcount > 0:
>
>                                     matchlist.append(line)
>
>                                     matchcount = matchcount - 1
>
>                                     print matchlist, matchcount
>
>                         else: tempfile.writelines(line)
>
>             if matchlist != []:
>
>                         for line in matchlist:
>
>                                     tempfile.writelines(line)
>
>                                     print line
>
>             else:   # figure out why this is erasing everything else and 
> writing
>
>                 # only the empty_group.
>
>                         filename = fxf_filename.split('.')
>
>                         name = filename[0].upper()
>
>                         empty_group = '''\tGroupName: 
> %s_empty\n\tFxInGroup: 0\n\tPhase: 10000\n'''%(name)
>
>                         tempfile.writelines(empty_group)
>
>             tempfile.close()
>
>
>
>###-------------------------------------###
>
>
>
>Thanks for any help...
>
>
>
>
>
>~Israel~
>
>


Bryce Embry
Geek-Of-All-Trades / Master-Of-None

www.bembry.org
--------------------------------------------------------------------------------------------------------------------------------------------------------
Technology Coordinator for MHA/FYOS ^ 390 South White Station ^ Memphis, TN 
38117 ^ (901)682-2409
--------------------------------------------------------------------------------------------------------------------------------------------------------
--=====================_363902874==_.ALT
Content-Type: text/html; charset="us-ascii"

<html>
Howdy, <br><br>
It looks like your problem stems from the difference in opening a file in
&quot;write&quot; mode and opening a file in &quot;append&quot;
mode.&nbsp; By default, write mode will automatically overwrite any text
currently in the file whenever you write to the file.&nbsp; This works
fine in your code when the desired text is already there, since it just
writes the text in again.&nbsp; But when the text is not already there,
you do not have the program write all the text again.&nbsp; It just
overwrites everything currently in the file with the text you desired.
<br><br>
You could fix this by using &quot;append&quot; mode when you open the
file, so that the line read: <br>
<font face="arial" size=2><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>tempfile
= open(os.path.join(fxdir, 'temp.fxf'), 'a')<br>
</font>(changed the &quot;w&quot; for an &quot;a&quot;).&nbsp; Or you
could just change the code so it writes the whole text in when the
matchlist is empty.&nbsp; <br><br>
Here's one way to that might work.&nbsp; I haven't tested it, but maybe
it will help: <br><br>
---<br>
&lt;revised code&gt;<br><br>
import re, os, os.path<br><br>
&nbsp;<br><br>
def move_empty(fxf_filename,
fxdir=r'C:\Dev\Tron\BUILD\Game\ClientFX'):<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
fxfilepath = os.path.join(fxdir, fxf_filename)<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fxfile
= open(fxfilepath, 'r')<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
fxfile.seek(0)<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; empty
= re.compile(&quot;GroupName:.*_empty&quot;)<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
matchlist = []<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
matchcount = 0<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
tempfile = open(os.path.join(fxdir, 'temp.fxf'), 'w')<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
fxfile_text = fxfile.readlines()<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for
line in fxfile_text:<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if empty.search(line):<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
matchlist.append(line)<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print matchlist<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
matchcount = 2<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
elif matchcount &gt; 0:<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
matchlist.append(line)<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
matchcount = matchcount - 1<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print matchlist, matchcount<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
else: tempfile.writelines(line)<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if
matchlist != []:<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
for line in matchlist:<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
tempfile.writelines(line)<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print line<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
else:&nbsp;&nbsp; # figure out why this is erasing everything else and
writing<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
# only the empty_group.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
filename = fxf_filename.split('.')<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
name = filename[0].upper()<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
empty_group = fxfile_text<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
empty_group_addition = '''\tGroupName: %s_empty\n\tFxInGroup: 0\n\tPhase:
10000\n'''%(name)<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
empty_group.append(empty_group_addition)<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
tempfile.writelines(empty_group)<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
tempfile.close()<br>
&lt;/revised code&gt;<br><br>
<br>
Hope that helps, <br>
Bryce<br><br>
At 12:00 PM 5/24/2002, you wrote:<br><br>
<blockquote type=cite class=cite cite><font face="arial" size=2>&nbsp;<br>
</font><br>
<font face="arial" size=2>Hello everyone..&nbsp;&nbsp; I'm attempting to
see if a file has a particular group of lines, and move them to the
end.&nbsp; If the file doesn't have this group, I'd like to add a basic
version of that group to the end anyways.&nbsp; The problem I'm having is
when the file doesn't have the group of lines I'm looking for.&nbsp; It
seems that my file.writelines() down at the end of the function in the
last else: block is overwriting the whole file with the little
group.&nbsp; What Am I missing?<br>
</font><br>
<font face="arial" size=2>&nbsp;<br>
</font><br>
<font face="arial" size=2>###--------------------------###<br>
</font><br>
<font face="arial" size=2>import re, os, os.path<br>
</font><br>
<font face="arial" size=2>&nbsp;<br>
</font><br>
<font face="arial" size=2>def move_empty(fxf_filename,
fxdir=r'C:\Dev\Tron\BUILD\Game\ClientFX'):<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
fxfilepath = os.path.join(fxdir, fxf_filename)<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
fxfile = open(fxfilepath, 'r')<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
fxfile.seek(0)<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
empty = re.compile(&quot;GroupName:.*_empty&quot;)<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
matchlist = []<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
matchcount = 0<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
tempfile = open(os.path.join(fxdir, 'temp.fxf'), 'w')<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
for line in fxfile.readlines():<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if empty.search(line):<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
matchlist.append(line)<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print matchlist<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
matchcount = 2<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
elif matchcount &gt; 0:<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
matchlist.append(line)<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
matchcount = matchcount - 1<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print matchlist, matchcount<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
else: tempfile.writelines(line)<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if matchlist != []:<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
for line in matchlist:<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
tempfile.writelines(line)<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print line<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
else:&nbsp;&nbsp; # figure out why this is erasing everything else and
writing<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
# only the
empty_group.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
filename = fxf_filename.split('.')<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
name = filename[0].upper()<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
empty_group = '''\tGroupName: %s_empty\n\tFxInGroup: 0\n\tPhase:
10000\n'''%(name)<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
tempfile.writelines(empty_group)<br>
</font><br>
<font face="arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
tempfile.close()<br>
</font><br>
<font face="arial" size=2>&nbsp;<br>
</font><br>
<font face="arial" size=2>###-------------------------------------###<br>
</font><br>
<font face="arial" size=2>&nbsp;<br>
</font><br>
<font face="arial" size=2>Thanks for any help...<br>
</font><br>
<font face="Times New Roman, Times">&nbsp;<br>
</font><br>
<font face="Times New Roman, Times">&nbsp;<br>
</font><br>
<font face="Courier New, Courier" size=2>~Israel~<br>
</font><br>
<font face="Times New Roman, Times">&nbsp;</blockquote>
<x-sigsep><p></x-sigsep>
<br>
Bryce Embry<br>
Geek-Of-All-Trades / Master-Of-None<br><br>
<a href="http://www.bembry.org/" eudora="autourl">www.bembry.org<br>
</a>--------------------------------------------------------------------------------------------------------------------------------------------------------<br>
Technology Coordinator for MHA/FYOS ^ 390 South White Station ^ Memphis,
TN 38117 ^ (901)682-2409<br>
--------------------------------------------------------------------------------------------------------------------------------------------------------</font></html>

--=====================_363902874==_.ALT--