473,386 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

file Error

Hi,
I am parsing an xml file,and using raw_input command to ask the
user to enter the file name.Ex
>>>
Enter The ODX File Path:

Suppose my code does not work properly,then in the python idle window
it shows something like this:
>>>
C:\Projects\ODX Import\Sample Files\MiscFiles
\CIM_A3300_diag_spec_sw49.xml
Traceback (most recent call last):
File "C:\Projects\ODX Import\code_ini\odxparse_mod_off_comm.py",
line 339, in <module>
process_variant(variant)
File "C:\Projects\ODX Import\code_ini\odxparse_mod_off_comm.py",
line 285, in process_variant
triplet = triplet + get_did_lengths(iservice,local_service_id)
File "C:\Projects\ODX Import\code_ini\odxparse_mod_off_comm.py",
line 238, in get_did_lengths
local_min = local_min + ddoref_min[ddorefstring]
KeyError: '_210'

This is some bug related to code ..thats ok..but when i run
the program immediately again for some other input..then it does not
show the prompt :
>>>
Enter The ODX File Path:

but instead a blinking prompt which accepts the
filename something like this:
>>>
C:\Projects\ODX Import\Sample Files\MiscFiles\Diagnostic CTS Global
Epsilon TIM V1.4.xml

I want the inputfile prompt to appear regardless of
the error condition.I dont know where the problem lies.Can someone
help me out.
Thanks

May 3 '07 #1
3 1018
En Thu, 03 May 2007 09:39:37 -0300, <sa**********@gmail.comescribió:
Hi,
I am parsing an xml file,and using raw_input command to ask the
user to enter the file name.Ex
>>>>
Enter The ODX File Path:

Suppose my code does not work properly,then in the python idle window
it shows something like this:
[...traceback...]
I want the inputfile prompt to appear regardless of
the error condition.I dont know where the problem lies.Can someone
help me out.
- IDLE is a development environment - don't use it to actually run your
program in production.

- Instead of asking the user to type the file name, accept it as a
parameter, that's what almost everyone else does in the world... It has
many advantages: you can associate your program with the filename
extension, you can use the "Send to..." menu, you can run it inside a
batch file, you can drop a file over your program to be processed, etc.

--
Gabriel Genellina
May 3 '07 #2
On May 3, 6:09 pm, "Gabriel Genellina" <gagsl-...@yahoo.com.arwrote:
En Thu, 03 May 2007 09:39:37 -0300, <saif.shak...@gmail.comescribió:
Hi,
I am parsing an xml file,and using raw_input command to ask the
user to enter the file name.Ex
Enter The ODX File Path:
Suppose my code does not work properly,then in the python idle window
it shows something like this:
[...traceback...]
I want the inputfile prompt to appear regardless of
the error condition.I dont know where the problem lies.Can someone
help me out.

- IDLE is a development environment - don't use it to actually run your
program in production.

- Instead of asking the user to type the file name, accept it as a
parameter, that's what almost everyone else does in the world... It has
many advantages: you can associate your program with the filename
extension, you can use the "Send to..." menu, you can run it inside a
batch file, you can drop a file over your program to be processed, etc.

--
Gabriel Genellina
Thanks for the reply........How do i accept the filename is a
parameter and avoid the error.Can you elaborate.

May 3 '07 #3
En Thu, 03 May 2007 10:15:52 -0300, <sa**********@gmail.comescribió:
Thanks for the reply........How do i accept the filename is a
parameter and avoid the error.Can you elaborate.
To get the arguments passed to the script, use sys.argv[]
Most introductory texts should cover it, like the Python tutorial:
http://docs.python.org/tut/node4.html

--
Gabriel Genellina
May 4 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Hans-Joachim Widmaier | last post by:
Hi all. Handling files is an extremely frequent task in programming, so most programming languages have an abstraction of the basic files offered by the underlying operating system. This is...
1
by: jase_dukerider | last post by:
Hi I have an assignment to hand in shortly for which I am after some guidance. The task is to read a WAV file, request a fade in /out time for the track from the user and the do the fade by...
7
by: Mark | last post by:
Hello, I have researched and tried every thing I have found on the web, in groups and MS KB articles. Here is what I have. I have a Windows 2000 Domain Controller all service packs and...
13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
6
by: tshad | last post by:
I have an upload file input as: <input id="MyFile" style="width:300px" type="File" runat="Server"> This works fine, but I find that if my page doesn't pass validation during postback, the page...
2
by: Dan | last post by:
Hi, I know this code is not entirely javascript, but bare with me. Can you please tell me why this does not work: page: filemanager.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
4
by: pank7 | last post by:
hi everyone, I have a program here to test the file IO(actually output) with buffer turned on and off. What I want to see is that there will be obvious differece in time. Here I have an input...
68
by: Martin Joergensen | last post by:
Hi, I have some files which has the following content: 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 0 0 0 0 0
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
Oralloy
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,...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.