I want to generate a script that produces html code. I have tried out must parts of the code from the shell .Somehow I always get errors if I check the modul.
please help me find the syntax errors...
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win32
Type "copyright" , "credits" or "license()" for more information.
*************** *************** *************** *************** ****
Personal firewall software may warn about the connection IDLE
makes to its subprocess using this computer's internal loopback
interface. This connection is not visible on any external
interface and no data is sent to or received from the Internet.
*************** *************** *************** *************** ****
IDLE 1.2
>>>
##generates html table code from CSV Files
##it must be copied to right section in html file for now
----------------------------------------------------------
---------------------------------------------------------------------
##this is an example of the table
##...
##<td align=\"right\" class=\"tableHi ghlightVertical \">smile</td>
##</tr>
##_____________ _______________ _______________ _______________ _
##_____________ _______________ _______________ _______________
##this is an exaple row of the csv
##1;Patrick Pleifer;16;6;13 ;0;20;0;55;0;55
##_____________ _______________ _______________ _______________ __
##_____________ _______________ _______________ _______________ ____
##
## First part read out csv, fill array
##_____________ _______________ _____________
## starting coding..definit ion of variables
import logging
##logging.basic Config(level=lo gging.DEBUG, doesn't work somehow
## format='%(ascti me)s %(levelname)s %(message)s',
## filename='/temp/myapp.log',
## filemode='w')
demitterCSV = ';'
CSVFile= 'meinfile.csv'
Outputfile ='outputfile.ht ml'
logging.debug(' csv demitter = ' + demitterCSV)
logging.debug(' csv file = ' + CSVFile)
logging.debug(' csv file = ' + Outputfile)
# used css styles in col order
ColStyleList = ['tableHighlight Vertical','tabl eStandardCenter MinWname','tabl eStandardCenter MinW','tableSta ndardCenterMinW ','tableStandar dCenterMinW','t ableStandardCen terMinW','table StandardCenterM inW','tableStan dardCenterMinW' ,
'tableStandardC enterMinW','tab leStandardCente rMinW','tableHi ghlightVertical ']
logging.debug(' css array generated = ' + ColStyleList)
numCol = len(ColStyleLis t)
import csv
#read data into a 2d array
array = []
#reader = csv.reader(open (CSVFile, "rb"), demitterCSV) doesn't work with variables(why?? )
reader = csv.reader(open ("meinfile.csv" , "rb"), delimiter=";")
logging.debug(' csv afile opened = ')
for row in reader:
array.append(ro w)
reader.close()
numRows= len(array)
if numRows ==len(array[1]:
logging.debugwa rning("csv format does not match table col format")
else:
logging.debug(' auslesen fertig ,array erzeugt; Anzahl Reihen = '+ numRows ' Spalten = '+ numCol)
#______________ _______________ __________
#______________ _______________ _______________ _
# First part is over :read out is complete
#Second part: generating html code
#______________ _______________ ______________-
# temporarly html code is safed in array
#
mycode =[]
mycode.append(" ""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">""")
mycode.append(' <html>')
mycode.append(' <head>')
mycode.append(" ""<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">""")
mycode.append(" ""<title>TI TLE</title>""")
mycode.append(" ""<link href="pokerDeta il.css" rel="stylesheet " type="text/css" />""")
mycode.append(" ""<style type="text/css">""")
rowdefstart = u'<tr height=\\\"19\\ \">'
rowdefend= r"</tr>"
colldefstart = '<td class=\\'
collstyladd= '"\>'
colldefend = r"</td>"
logging.debug(" Header in temp array")
logging.debug(m ycode)
numRows= len(array)
#<td class=\"tableHi ghlightVertical \">smile</td>
row=0
col=0
tmp= "tmp"
while row < numRows:
logging.debug(( "counter " + str(row)+" < " + str(numRows))
#mycode.append( rowdefstart)
while col <numCol:
logging.debug(" outer " + str(row)+ " counter " + str(col)+" < "+ str(numCol))
tmp=(colldefsta rt + ColStyleList[col] + collstyladd+str (array[row][col])+ colldefend)
mycode.append(s )
col = col + 1
col = 0
row = row + 1
logging.debug()
# tmp string is needed, if you put sequence escape string direcly in array
# it screws it, see below
#<td class=\\tableHi ghlightVertical "\\>1.</td>' instead of
#<td class=\"tableHi ghlightVertical \">smile</td>
writer = csv.writer(open ("some.csv", "wb"))
writer.writerow s(mycode)
logging.debug(" finished")
Thanks for your help. I am really curious as I normally cope with java.
At least I was able to solve some (previous) errors like escape sequence myself...but now I am kind of stuck
please help me find the syntax errors...
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win32
Type "copyright" , "credits" or "license()" for more information.
*************** *************** *************** *************** ****
Personal firewall software may warn about the connection IDLE
makes to its subprocess using this computer's internal loopback
interface. This connection is not visible on any external
interface and no data is sent to or received from the Internet.
*************** *************** *************** *************** ****
IDLE 1.2
>>>
##generates html table code from CSV Files
##it must be copied to right section in html file for now
----------------------------------------------------------
---------------------------------------------------------------------
##this is an example of the table
##...
##<td align=\"right\" class=\"tableHi ghlightVertical \">smile</td>
##</tr>
##_____________ _______________ _______________ _______________ _
##_____________ _______________ _______________ _______________
##this is an exaple row of the csv
##1;Patrick Pleifer;16;6;13 ;0;20;0;55;0;55
##_____________ _______________ _______________ _______________ __
##_____________ _______________ _______________ _______________ ____
##
## First part read out csv, fill array
##_____________ _______________ _____________
## starting coding..definit ion of variables
import logging
##logging.basic Config(level=lo gging.DEBUG, doesn't work somehow
## format='%(ascti me)s %(levelname)s %(message)s',
## filename='/temp/myapp.log',
## filemode='w')
demitterCSV = ';'
CSVFile= 'meinfile.csv'
Outputfile ='outputfile.ht ml'
logging.debug(' csv demitter = ' + demitterCSV)
logging.debug(' csv file = ' + CSVFile)
logging.debug(' csv file = ' + Outputfile)
# used css styles in col order
ColStyleList = ['tableHighlight Vertical','tabl eStandardCenter MinWname','tabl eStandardCenter MinW','tableSta ndardCenterMinW ','tableStandar dCenterMinW','t ableStandardCen terMinW','table StandardCenterM inW','tableStan dardCenterMinW' ,
'tableStandardC enterMinW','tab leStandardCente rMinW','tableHi ghlightVertical ']
logging.debug(' css array generated = ' + ColStyleList)
numCol = len(ColStyleLis t)
import csv
#read data into a 2d array
array = []
#reader = csv.reader(open (CSVFile, "rb"), demitterCSV) doesn't work with variables(why?? )
reader = csv.reader(open ("meinfile.csv" , "rb"), delimiter=";")
logging.debug(' csv afile opened = ')
for row in reader:
array.append(ro w)
reader.close()
numRows= len(array)
if numRows ==len(array[1]:
logging.debugwa rning("csv format does not match table col format")
else:
logging.debug(' auslesen fertig ,array erzeugt; Anzahl Reihen = '+ numRows ' Spalten = '+ numCol)
#______________ _______________ __________
#______________ _______________ _______________ _
# First part is over :read out is complete
#Second part: generating html code
#______________ _______________ ______________-
# temporarly html code is safed in array
#
mycode =[]
mycode.append(" ""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">""")
mycode.append(' <html>')
mycode.append(' <head>')
mycode.append(" ""<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">""")
mycode.append(" ""<title>TI TLE</title>""")
mycode.append(" ""<link href="pokerDeta il.css" rel="stylesheet " type="text/css" />""")
mycode.append(" ""<style type="text/css">""")
rowdefstart = u'<tr height=\\\"19\\ \">'
rowdefend= r"</tr>"
colldefstart = '<td class=\\'
collstyladd= '"\>'
colldefend = r"</td>"
logging.debug(" Header in temp array")
logging.debug(m ycode)
numRows= len(array)
#<td class=\"tableHi ghlightVertical \">smile</td>
row=0
col=0
tmp= "tmp"
while row < numRows:
logging.debug(( "counter " + str(row)+" < " + str(numRows))
#mycode.append( rowdefstart)
while col <numCol:
logging.debug(" outer " + str(row)+ " counter " + str(col)+" < "+ str(numCol))
tmp=(colldefsta rt + ColStyleList[col] + collstyladd+str (array[row][col])+ colldefend)
mycode.append(s )
col = col + 1
col = 0
row = row + 1
logging.debug()
# tmp string is needed, if you put sequence escape string direcly in array
# it screws it, see below
#<td class=\\tableHi ghlightVertical "\\>1.</td>' instead of
#<td class=\"tableHi ghlightVertical \">smile</td>
writer = csv.writer(open ("some.csv", "wb"))
writer.writerow s(mycode)
logging.debug(" finished")
Thanks for your help. I am really curious as I normally cope with java.
At least I was able to solve some (previous) errors like escape sequence myself...but now I am kind of stuck
Comment