Hi,
I coded a python script that lets me parse a csv file into html code
with a certain format, but I would like to replace every "<" and ">"
character that appears within each column entry of the csv file (they
are parsed as strings) with the html equivalents of "<" and ">".
example csv file row:
"FIXED","All"," Enable <audioentry"
and I want to replace <audiowith <audio> ; before I do a
"<p>This is a " + str(array[0]) + " bug that applies to " +
str(array[1]) + " platforms and has the description: " + str(array[2]) +
".</p>"
to get the following html code:
<p>This is a FIXED bug that applies to All platforms and has the
description: Enable <audio> ; entry.</p>
(sometimes < appears twice or thrice and sometimes only appears so
they are not necessarily appearing together, e.g. -instead of <something>)
How should I go about doing it?
Regards. 2 2463
On Sat, Nov 8, 2008 at 9:16 PM, John Smith <sw****@gmail.c omwrote:
Hi,
I coded a python script that lets me parse a csv file into html code with a
certain format, but I would like to replace every "<" and ">" character that
appears within each column entry of the csv file (they are parsed as
strings) with the html equivalents of "<" and ">".
You want the cgi.escape() function - http://docs.python.org/library/cgi.html#cgi.escape
Cheers,
Chris
--
Follow the path of the Iguana... http://rebertia.com
>
example csv file row:
"FIXED","All"," Enable <audioentry"
and I want to replace <audiowith <audio> ; before I do a
"<p>This is a " + str(array[0]) + " bug that applies to " + str(array[1]) +
" platforms and has the description: " + str(array[2]) + ".</p>"
to get the following html code:
<p>This is a FIXED bug that applies to All platforms and has the
description: Enable <audio> ; entry.</p>
(sometimes < appears twice or thrice and sometimes only appears so they
are not necessarily appearing together, e.g. -instead of <something>)
How should I go about doing it?
Regards.
-- http://mail.python.org/mailman/listinfo/python-list
Chris Rebert wrote:
On Sat, Nov 8, 2008 at 9:16 PM, John Smith <sw****@gmail.c omwrote:
>Hi,
I coded a python script that lets me parse a csv file into html code with a certain format, but I would like to replace every "<" and ">" character that appears within each column entry of the csv file (they are parsed as strings) with the html equivalents of "<" and ">".
FYI: Python strings do have a .replace method,
but for the above application
You want the cgi.escape() function - http://docs.python.org/library/cgi.html#cgi.escape
*is* what you should use, as it will do all needed replacements in one call. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Xah Lee |
last post by:
i have a bunch of java files that has spaced-out formatting that i
want to get rid of. I want to replace two end of line characters by
one end of line characters. The files in question is unix, and i'm
also working under unix, so i did:
perl -pi'*~' -e "s@\n\n@\n@g" *.java
but this to no avail.
after many minutes of checking and rechecking and lots of trial and
|
by: Mike |
last post by:
Hi, I am using Python to scrape web pages and I do not have problem
unless I run into a site that is utf-8. It seems & is changed to &
when the site is utf-8.
If I try to replace it with .replace('&','&') it for some reason
does not replace it.
For example: http://today.reuters.co.uk/news/default.aspx
The url in the page looks like this
|
by: VMI |
last post by:
If I have the string "Héllo", how can I replace char (é) with an 'e'? I
cannot use the String.Replace() fuction. It has to be by replacing one char
with another.
Thanks.
|
by: Adam J. Schaff |
last post by:
I am writing a quick program to edit a binary file that contains file paths
(amongst other things). If I look at the files in notepad, they look like:
<gibberish>file//g:\pathtofile1<gibberish>file//g:\pathtofile2<gibberish>
etc.
I want to remove the "g:\" from the file paths. I wrote a console app that
successfully reads the file and writes a duplicate of it, but fails for some
reason to do the "replacing" of the "g:\". The code...
|
by: Alain |
last post by:
Hi,
I am working on a project where I need to convert international characters
with acii values. Like André -> andre and Björn -> bjorn.
How can I do this without replacing every single character?
lastname = lastname.Replace("â", "a");
lastname = lastname.Replace("é", "e");
lastname = lastname.Replace("ö", "o");
| |
by: Adnan Siddiqi |
last post by:
Hi
Suppose I have following URLs comming from an HTML document
<a href="http://mydomain1.com">Domain1</a>
<a
href="http://subdomain.domain.com/myfile.anyext">http://subdomain.domain.com/myfile.anyext</a>
<a href="http://subdomain.domain2.com/myfile.anyext">Domain2</a>
|
by: Josh Baltzell |
last post by:
I am having a lot more trouble with this than I thought I would. Here
is what I want to do in pseudocode.
Open c:\some.pdf
Replace "Replace this" with "Replaced!"
Save c:\some_edited.pdf
I can do this in notepad and it works fine, but when I start getting in
to reading the files I think it has some encoding problem. I tried
saving the file with every encoding option. When I open a PDF in the
|
by: David |
last post by:
Sent this to alt.php a couple of days back, but doesn't look like I'll
get an answer, so trying here.
I'm trying to convert a script to use friendly URLs, I've done this
before, but my PHP skills are quite basic so far, far from proficient
at this.
..htaccess file-
DirectoryIndex default.php index.asp index.html index.htm index.php
|
by: Trev |
last post by:
Hi everyone,
I'm having some problems using Regex; I have a long string that is
delimetered in a random fashion by a combination of spaces and \n's for
newlines. I have five possiblities:
// Character can be a-zA-Z0-9 plus any non-alphanumeric character (. ,
\ etc.)
// five possibilities:
// 1: Characters \nCharacters -Characters Characters
// 2: Characters\n Characters -Characters Characters
|
by: gsuns82 |
last post by:
Hi all,
I have to replace accented characters from a input string with
normal plain text.I have coded as follows.
String input = "ÄÀÁÂÃ";
input= input.replaceAll("", "A"); like wise v can do for all.
output was:
************
AAAAA
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |