Need some help on parsing a file - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32) +--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26) +--- Thread: Need some help on parsing a file (/showthread.php?tid=8120) |
- fluidman - 2004-12-11 hi, i am trying to get startet on programming with python... implementing and changing available scripts around a bit is working out alright for me.. but now i am trying to get startet on some own stuff. could one of you crazy pathon gurus just help me get startet on some things.. for example.. lets say i want to read in a html file that lays on http://www.blah.com/blah.html and display the data thats within a table in that file on xbmc.. lets say the html file looks like this: Quote:<html> how would i read in each row, parse it, and display it on the xbmc screen? could one of you help me get jump startet on this.. i tried some things but it diddnt quite work out the right way, hehe. thanks in advance - Kaer - 2004-12-11 im a newbie at python but maybe this can help u off till better help arrives! :d try use regular expression to grab the lines that start with <td> and ends with </tr> use another regular expression to replace <terms> with tabs. then just format it in a way u like? im not sure, this aint so easy now that im looking at it lol :d - fluidman - 2004-12-11 i always had pproblems with those stupid regular expressions. can someone post some sample code that would fit my example from the 1st post? - Kaer - 2004-12-11 xre = re.compile('^<td>(.*)</tr>') p = re.compile( '(<.*>)') links = xre.findall(data) for link in links: name = p.sub (' ', link[0]) # replaces the <td> or </td> with spaces it might work heh - fluidman - 2004-12-12 how do i access and open the file again? - Asteron - 2004-12-14 keep an eye out on the upload page :-) i just submitted a script very similar to this (parses information from an html table and opens files). should be there tomorrow. to do file stuff though you do Quote:f = open(filename,'r') -asteron - fluidman - 2004-12-14 great.. sounds great. i'll check it out. thanks to both of you :thumbsup: |