<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-2">
<META content="MSHTML 6.00.2800.1515" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV dir=ltr align=left><SPAN class=385224310-07102005><FONT
face="Courier New">... jedno spíš rychlé, než krásné
řešení...</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=385224310-07102005><FONT
face="Courier New"></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN
class=385224310-07102005>==============================================</SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=385224310-07102005><FONT
face="Courier New">fin = file('vstup.txt')</FONT></SPAN></DIV>
<DIV><FONT face="Courier New"></FONT> </DIV>
<DIV dir=ltr align=left><SPAN class=385224310-07102005><FONT
face="Courier New">mnozina = set()<BR>fname = ''<BR>sec = ''<BR>kod =
''</FONT></SPAN></DIV>
<DIV><FONT face="Courier New"></FONT> </DIV>
<DIV dir=ltr align=left><SPAN class=385224310-07102005><FONT
face="Courier New">for line in fin:<BR> if line.strip() ==
'':<BR> continue #
preskakujeme prazdne radky<BR>
<BR> if line[0] != '
':<BR> fname =
line.strip() # Nazev souboru. </FONT></SPAN></DIV>
<DIV><FONT face="Courier New"></FONT> </DIV>
<DIV dir=ltr align=left><SPAN class=385224310-07102005><FONT
face="Courier New"> elif line[1] ==
'*':<BR> sec =
line[2:].strip() # Identifikace sekce.</FONT></SPAN></DIV>
<DIV><FONT face="Courier New"></FONT> </DIV>
<DIV dir=ltr align=left><SPAN class=385224310-07102005><FONT
face="Courier New">
else:<BR> kod =
line.strip()<BR> assert
kod.startswith('KOD')<BR>
mnozina.add('%s|%s|%s' % (fname, sec,
kod))<BR>
<BR>fin.close()</FONT></SPAN></DIV>
<DIV><FONT face="Courier New"></FONT> </DIV>
<DIV dir=ltr align=left><SPAN class=385224310-07102005><FONT
face="Courier New"># Serazeny seznam.</FONT></SPAN></DIV>
<DIV><SPAN class=385224310-07102005><FONT face="Courier New">lst =
sorted(list(mnozina))</FONT></SPAN></DIV>
<DIV><FONT face="Courier New"></FONT> </DIV>
<DIV dir=ltr align=left><SPAN class=385224310-07102005><FONT
face="Courier New">fout = file('vystup.txt', 'w')</FONT></SPAN></DIV>
<DIV><FONT face="Courier New"></FONT> </DIV>
<DIV dir=ltr align=left><SPAN class=385224310-07102005><FONT
face="Courier New">fname = ''<BR>sec = ''</FONT></SPAN></DIV>
<DIV><FONT face="Courier New"></FONT> </DIV>
<DIV dir=ltr align=left><SPAN class=385224310-07102005><FONT
face="Courier New">for item in lst:<BR> f, s, k =
item.split('|')<BR> <BR> if f !=
fname:<BR> fname =
f<BR> sec =
''<BR> fout.write('\n' + fname +
'\n')</FONT></SPAN></DIV>
<DIV><FONT face="Courier New"></FONT> </DIV>
<DIV dir=ltr align=left><SPAN class=385224310-07102005><FONT
face="Courier New"> if s !=
sec:<BR> sec =
s<BR> fout.write(' * %s\n' %
sec)</FONT></SPAN></DIV>
<DIV><FONT face="Courier New"></FONT> </DIV>
<DIV dir=ltr align=left><SPAN class=385224310-07102005><FONT
face="Courier New"> fout.write(' %s\n'
% kod)<BR>
<BR>fout.close()</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN
class=385224310-07102005>==============================================</SPAN></DIV>
<DIV><SPAN class=385224310-07102005></SPAN><FONT
face="Courier New"></FONT> </DIV>
<DIV><FONT face="Courier New">p<SPAN
class=385224310-07102005>epr</SPAN></FONT><BR></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=cs dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> python-bounces@py.cz
[mailto:python-bounces@py.cz] <B>On Behalf Of </B>Martin
Jedlička<BR><B>Sent:</B> Thursday, October 06, 2005 2:05 PM<BR><B>To:</B>
python@py.cz<BR><B>Subject:</B> [python] odstraneni radku v
souboru<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV><FONT face=Arial size=2>jo, diky toto funguje super az na jednu vec.
Pokud v tom souboru nejsou ty cisla za hvezdickou serazeny, tj. vypada to
napr. takto:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV>nazev souboru1<BR> * 1.3:<BR>
KOD-01-01-01-06<BR> * 1.4:<BR>
KOD-01-01-01-04<BR> * 1.4:<BR>
KOD-01-01-01-13<BR> * 1.3:<BR>
KOD-01-01-01-01<BR> * 1.3:<BR>
KOD-01-01-01-02<BR> * 1.3:<BR>
KOD-01-01-01-05<BR> * 1.3:<BR>
KOD-01-01-01-07</DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV>tak to udela toto:</DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>
<DIV><FONT face="Times New Roman" size=3>nazev souboru1<BR> *
1.3:<BR> KOD-01-01-01-06<BR> *
1.4:<BR> KOD-01-01-01-04<BR>
KOD-01-01-01-13<BR>
KOD-01-01-01-01<BR>
KOD-01-01-01-02<BR>
KOD-01-01-01-05<BR> KOD-01-01-01-07</FONT></DIV>
<DIV><FONT face="Times New Roman" size=3></FONT> </DIV>
<DIV><FONT face="Times New Roman" size=3>a melo to udelat tohle:</FONT></DIV>
<DIV><FONT face="Times New Roman" size=3></FONT> </DIV>
<DIV><FONT face="Times New Roman" size=3>nazev souboru1<BR> *
1.3:<BR> KOD-01-01-01-06</FONT></DIV>
<DIV><FONT face="Times New Roman" size=3>
KOD-01-01-01-01<BR>
KOD-01-01-01-02<BR>
KOD-01-01-01-05<BR> KOD-01-01-01-07<BR> *
1.4:<BR> KOD-01-01-01-04<BR>
KOD-01-01-01-13<BR></DIV></FONT><FONT face="Times New Roman" size=3></FONT>
<DIV><FONT face="Times New Roman" size=3>co s tim?</FONT></DIV>
<DIV><FONT face="Times New Roman" size=3></FONT> </DIV>
<DIV><FONT face="Times New Roman" size=3>diky</FONT></DIV>
<DIV></DIV></FONT></DIV></BLOCKQUOTE></BODY></HTML>