Hi,
I am parsing an xml file ,before that i have replaced a string in
the original xml file with another and made a new xml file which will
now be parsed.I am also opening some more files for output.The
following code shows some i/o commands.
file_input = raw_input("Enter The ODX File Path:")
input_xml = open(file_input,'r')
(shortname,ext)=os.path.splitext(file_input)
f_open_out=shortname+".ini"
log=shortname+".xls"
test_file=shortname+"testxml.xml"
saveout = sys.stdout
xmlcont=input_xml.read()
input_xml.close()
xmlcont=xmlcont.replace('localId','dataPackageId')
output_file = open(test_file,"w")
output_file.write(xmlcont)
output_file.close()
f_open=open(f_open_out, 'w')
logfile=open(log,"w")
sys.stdout = f_open
After this i have to parse the new xml file which is in
output_file .hence
input_xml_sec = open(output_file,'r')
xmldoc = minidom.parse(input_xml_sec)
But i am getting an error on this line
(input_xml_sec = open(output_file,'r')).I have tried to figure out but
not able to debug.Can someone throw some light or anything they feel
could be going wrong somewhere.
Thanks 6 1052 sa**********@gmail.com wrote:
Hi,
I am parsing an xml file ,before that i have replaced a string in
the original xml file with another and made a new xml file which will
now be parsed.I am also opening some more files for output.The
following code shows some i/o commands.
file_input = raw_input("Enter The ODX File Path:")
input_xml = open(file_input,'r')
(shortname,ext)=os.path.splitext(file_input)
f_open_out=shortname+".ini"
log=shortname+".xls"
test_file=shortname+"testxml.xml"
saveout = sys.stdout
xmlcont=input_xml.read()
input_xml.close()
xmlcont=xmlcont.replace('localId','dataPackageId')
output_file = open(test_file,"w")
output_file.write(xmlcont)
output_file.close()
f_open=open(f_open_out, 'w')
logfile=open(log,"w")
sys.stdout = f_open
After this i have to parse the new xml file which is in
output_file .hence
input_xml_sec = open(output_file,'r')
xmldoc = minidom.parse(input_xml_sec)
But i am getting an error on this line
(input_xml_sec = open(output_file,'r')).I have tried to figure out but
not able to debug.Can someone throw some light or anything they feel
could be going wrong somewhere.
How about telling us what the error is?
Suggested read: http://www.catb.org/~esr/faqs/smart-questions.html
Diez
Diez sa**********@gmail.com wrote:
output_file = open(test_file,"w")
...
input_xml_sec = open(output_file,'r')
Can you spot the problem now? To prevent it, use a naming convention that
allows you to distinguish between file /names/ and file /objects/.
But i am getting an error on this line
(input_xml_sec = open(output_file,'r')).I have tried to figure out but
not able to debug.Can someone throw some light or anything they feel
could be going wrong somewhere.
In the future, to make it as easy as possible to help you, please post the
actual traceback which contains valuable hints about the error you
encountered even if you cannot make sense of it.
Peter
On May 16, 7:55 pm, Peter Otten <__pete...@web.dewrote:
saif.shak...@gmail.com wrote:
output_file = open(test_file,"w")
...
input_xml_sec = open(output_file,'r')
Can you spot the problem now? To prevent it, use a naming convention that
allows you to distinguish between file /names/ and file /objects/.
But i am getting an error on this line
(input_xml_sec = open(output_file,'r')).I have tried to figure out but
not able to debug.Can someone throw some light or anything they feel
could be going wrong somewhere.
In the future, to make it as easy as possible to help you, please post the
actual traceback which contains valuable hints about the error you
encountered even if you cannot make sense of it.
Peter
Hi,
I am running the exe from command prompt,but i am not able to see
the error as it goes off very quickly.How do i capture the error
(traceback).I tried putting an input prompt after the expected line of
error but wont work.Is there a command to capture the error.
Thanks
On May 18, 1:01 pm, Peter Otten <__pete...@web.dewrote:
saif.shak...@gmail.com wrote:
I am running the exe from command prompt,but i am not able to see
the error as it goes off very quickly.
http://effbot.org/pyfaq/how-do-i-run...er-windows.htm
How do i capture the error (traceback).I tried putting an input prompt
after the expected line of error but wont work.Is there a command to
capture the error.
You can redirect stderr to a file:
http://www.microsoft.com/resources/d...s/xp/all/prodd...
Peter
ok i traced the error for above code.It says something like this:
Traceback (most recent call last):
File "C:\Projects\ODX Import\code_ini\odxparse_mod.py", line 294, in
<module>
input_xml_sec = open(output_file,'r')
TypeError: coercing to Unicode: need string or buffer, file found
Can someone help me in this.
Thanks sa**********@gmail.com wrote:
On May 18, 1:01 pm, Peter Otten <__pete...@web.dewrote:
>saif.shak...@gmail.com wrote:
I am running the exe from command prompt,but i am not able to see
the error as it goes off very quickly.
http://effbot.org/pyfaq/how-do-i-run...er-windows.htm
How do i capture the error (traceback).I tried putting an input prompt
after the expected line of error but wont work.Is there a command to
capture the error.
You can redirect stderr to a file:
http://www.microsoft.com/resources/d...s/xp/all/prodd...
Peter
ok i traced the error for above code.It says something like this:
Traceback (most recent call last):
File "C:\Projects\ODX Import\code_ini\odxparse_mod.py", line 294, in
<module>
input_xml_sec = open(output_file,'r')
TypeError: coercing to Unicode: need string or buffer, file found
Can someone help me in this.
Thanks
I already pointed you to the error in my first post in this thread.
output_file is a file, but open() expects a file name.
Peter This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Larry R Harrison Jr |
last post by:
I have an Access 2000/XP with an unusual autonumber scheme; I can't figure
out how it generates its very unique value.
I have the database temporarily located at this website:
...
|
by: Farooq Khan |
last post by:
why does Response.Write in a method of code-beind class when called from
inpage code (i.e in <%---%>), after creating object of that class, fails
when called
while it works perfectly ok while...
|
by: alex.krupp |
last post by:
I have this webpage where I am getting the dreaded float drop bug in
IE. I tried everything in the float drop FAQs online, but nothing can
get it working. I have narrowed down the problem though....
|
by: Joe |
last post by:
Hi,
I want to save some URLs into a XML formatted document.
I find out that its having some problems due to some of the characters used
in the URL.
Is there a quick way to get around that? ...
|
by: John Howie |
last post by:
I've found very unusual behavious when using sessions on two different
servers.
I'm using sessions to handle simple log in. When the form submits the
values are checked against a MySQL table. If...
|
by: brett.estabrook |
last post by:
I have written a multi-threaded c# windows service in .net 1.1 (Visual
Studio .net 2003). The service has several threads that poll a Sql 6.5
database on another machine. Each thread will execute a...
|
by: Bobby |
last post by:
Hi,
I'm not 100% sure that this is an Access problem. A friend of mine has
an Access 2003 database. Occasionally he brings a copy to me so that I
can import some of his data into my Access 2003...
|
by: MrCC via AccessMonster.com |
last post by:
Dear All
well i want to say that this forum is from the best access forums in the
internet really ,many problems & bugs solved by this forum expert :)
Indeed i need to know what also the best...
|
by: sheldonlg |
last post by:
I got an unusual request. One customer wants a password/access made
available to a user that is valid for only, say, ten minutes. I know
that I can enforce this by having a revalidation of the...
|
by: Newbie |
last post by:
Hello I need to enter a string of the form abc (a string of
characters followed by EOF)
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 100
int main(void)
{
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
| |