473,394 Members | 1,817 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,394 software developers and data experts.

Code not work - DESPERATE HELP :(


Hi,

i am trying to convert an .osm (openstreetmap) file into gml format and
finally to shapefile given this wiki info
http://wiki.openstreetmap.org/index.php/GML. I'm using windows and when i
entered the following commands osm2gml.py < map_01_data.osm >
map_01_data.gml on my dos prompt i get a number of errors, some of which
are bellow:

Traceback <most recent call last>:
File "C:\osm2gml.py, line 86, in <module>
xml.sax.parse <sys.stdin, osmParser >
IOError : [Errono 9] bad discriptor

i did manage to convert it to gml format but was clearly unsuccesful because
of the error and it was 1kb.
Another point i would like to add is that ran the file using PythonWin
(ActiveState) with map_01_data.osm as the argument and after hitting ok,
then cancel i got

Traceback (most recent call last):
File
"C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py" ,
line 310, in RunScript
exec codeObject in __main__.__dict__
File "C:\osm2gml.py", line 86, in <module>
xml.sax.parse( sys.stdin, osmParser )
File "C:\Python25\lib\xml\sax\__init__.py", line 33, in parse
parser.parse(source)
File "C:\Python25\lib\xml\sax\expatreader.py", line 107, in parse
xmlreader.IncrementalParser.parse(self, source)
File "C:\Python25\lib\xml\sax\xmlreader.py", line 123, in parse
self.feed(buffer)
File "C:\Python25\lib\xml\sax\expatreader.py", line 211, in feed
self._err_handler.fatalError(exc)
File "C:\Python25\lib\xml\sax\handler.py", line 38, in fatalError
raise exception
SAXParseException: <stdin>:1:0: syntax error

Please would somebody mind telling how i can covert my osm file into the
..gml format using the python file on the dos command or using pythonwin.

Cheers
--
View this message in context: http://www.nabble.com/Code-not-work-...p20253039.html
Sent from the Python - python-list mailing list archive at Nabble.com.

Oct 30 '08 #1
19 1797
On 2008-10-30, fx5900 <lu*******@hotmail.comwrote:
Hi,
i am trying to convert an .osm (openstreetmap) file into gml format and
finally to shapefile given this wiki info
http://wiki.openstreetmap.org/index.php/GML. I'm using windows and when i
entered the following commands osm2gml.py < map_01_data.osm >
map_01_data.gml on my dos prompt i get a number of errors, some of which
are bellow:
Does this give any better results:

python osm2gml.py < map_01_data.osm map_01_data.gml

-Bill
--
Sattre Press In the Quarter
http://sattre-press.com/ by Robert W. Chambers
in**@sattre-press.com http://sattre-press.com/itq.html
Oct 30 '08 #2

Hi,

I just went to go and get a coffee when i noticed a email, thought it was
just usual spam. Read your message, and it worked. it was because i did not
put they 'python' keyword infront. How did u figure it out?

Although, cos i nver worked with python, things are bound to go wrong on the
first hurdles right?

Cheers :)
Bill McClain-4 wrote:
>
On 2008-10-30, fx5900 <lu*******@hotmail.comwrote:
>Hi,
> i am trying to convert an .osm (openstreetmap) file into gml format
and
finally to shapefile given this wiki info
http://wiki.openstreetmap.org/index.php/GML. I'm using windows and when i
entered the following commands osm2gml.py < map_01_data.osm >
map_01_data.gml on my dos prompt i get a number of errors, some of which
are bellow:

Does this give any better results:

python osm2gml.py < map_01_data.osm map_01_data.gml

-Bill
--
Sattre Press In the Quarter
http://sattre-press.com/ by Robert W. Chambers
in**@sattre-press.com http://sattre-press.com/itq.html
--
http://mail.python.org/mailman/listinfo/python-list

--
View this message in context: http://www.nabble.com/Code-not-work-...p20255455.html
Sent from the Python - python-list mailing list archive at Nabble.com.

Oct 30 '08 #3
On 2008-10-30, fx5900 <lu*******@hotmail.comwrote:
I just went to go and get a coffee when i noticed a email, thought it was
just usual spam. Read your message, and it worked. it was because i did not
put they 'python' keyword infront. How did u figure it out?
It is some problem with the DOS box on Windows. I believe the standard input
and output get lost somehow. I just encountered it myself. Using the "python"
command is not required on other platforms--Linux, for example.

If anyone has a more elegant solution I would like to hear it. I hate
documenting "this way on Windows, another way everywhere else..."

-Bill
--
Sattre Press In the Quarter
http://sattre-press.com/ by Robert W. Chambers
in**@sattre-press.com http://sattre-press.com/itq.html
Oct 30 '08 #4
On approximately 10/30/2008 2:13 PM, came the following characters from
the keyboard of Bill McClain:
On 2008-10-30, fx5900 <lu*******@hotmail.comwrote:

> I just went to go and get a coffee when i noticed a email, thought it was
just usual spam. Read your message, and it worked. it was because i did not
put they 'python' keyword infront. How did u figure it out?

It is some problem with the DOS box on Windows. I believe the standard input
and output get lost somehow. I just encountered it myself. Using the "python"
command is not required on other platforms--Linux, for example.

If anyone has a more elegant solution I would like to hear it. I hate
documenting "this way on Windows, another way everywhere else..."

-Bill
The problem with stdin/stdout is on Windows 2000 (and maybe the earlier
NT?). But not on XP or AFAIK Vista.

It only occurs when a program is executed indirectly using the file
associations instead of directly via the command line.

File associations, are the Windows "let's do it a different way"
alternative for Unix she-bang lines (#!/path/to/python).

--
Glenn -- http://nevcal.com/
===========================
A protocol is complete when there is nothing left to remove.
-- Stuart Cheshire, Apple Computer, regarding Zero Configuration Networking

Oct 31 '08 #5
On 2008-10-31, Glenn Linderman <v+******@g.nevcal.comwrote:
The problem with stdin/stdout is on Windows 2000 (and maybe the earlier
NT?). But not on XP or AFAIK Vista.
It only occurs when a program is executed indirectly using the file
associations instead of directly via the command line.
File associations, are the Windows "let's do it a different way"
alternative for Unix she-bang lines (#!/path/to/python).
Can you elaborate on this? I have some very simple command-line utilities I
would like to make available on different platforms, but what little I knew
about Windows is fading into the past.

This example:

import sys
print sys.stdin.read()

....works in the Windows XP dos box if I do:

python demo.py < file.txt

....but I get the error 9 for:

demo.py < file.txt

Is there any way to make the second version work on Windows?

-Bill
--
Sattre Press The King in Yellow
http://sattre-press.com/ by Robert W. Chambers
in**@sattre-press.com http://sattre-press.com/kiy.html
Oct 31 '08 #6
Bill McClain wrote:
On 2008-10-31, Glenn Linderman <v+******@g.nevcal.comwrote:
>The problem with stdin/stdout is on Windows 2000 (and maybe the earlier
NT?). But not on XP or AFAIK Vista.
>It only occurs when a program is executed indirectly using the file
associations instead of directly via the command line.
>File associations, are the Windows "let's do it a different way"
alternative for Unix she-bang lines (#!/path/to/python).

Can you elaborate on this? I have some very simple command-line utilities I
would like to make available on different platforms, but what little I knew
about Windows is fading into the past.

This example:

import sys
print sys.stdin.read()

...works in the Windows XP dos box if I do:

python demo.py < file.txt

...but I get the error 9 for:

demo.py < file.txt

Is there any way to make the second version work on Windows?
You've got a few options. Perhaps the simplest is to use something
like the effbots exemaker [1] which creates a stub for your script
but which is an .exe to the redirection should work. The user has
to have Python installed on the system (it's not a py2exe lookalike)
but it can make things like this simpler.

I believe -- but I've never really gone into this -- that the
setuptools extensions to distutils offer a way to do this as
part of the installation, so if you were having the scripts
installed via a setup.py (or setup.whetever) then that might
be the way.

Obviously py2exe (also a distutils extension) is another
possibility, altho' I would see it here as a fallback option
since it's a bit more heavyweight.

This is the MS article which describes the problem:

http://support.microsoft.com/kb/321788

and suggests that it's fixed in XP SP1 but this
thread:

http://mail.python.org/pipermail/pyt...er/506466.html

suggests that maybe it's not.

TJG
Oct 31 '08 #7
On 2008-10-31, Tim Golden <ma**@timgolden.me.ukwrote:
You've got a few options.
Ok, thanks!

It is a small hobbyist community. I'll just document it and tell them "life is
hard for Windows users."

-Bill
--
Sattre Press The King in Yellow
http://sattre-press.com/ by Robert W. Chambers
in**@sattre-press.com http://sattre-press.com/kiy.html
Oct 31 '08 #8
Bill McClain wrote:
On 2008-10-31, Tim Golden <ma**@timgolden.me.ukwrote:
>You've got a few options.

Ok, thanks!

It is a small hobbyist community. I'll just document it and tell them "life is
hard for Windows users."
Well I don't know any Windows users that still use DOS-boxes ;-)
cheers,
Stef
-Bill
Oct 31 '08 #9
On 2008-10-31, Stef Mientki <st**********@gmail.comwrote:
Well I don't know any Windows users that still use DOS-boxes ;-)
cheers,
What do they do when they want to run a cross-platform command-line script
with parameters and redirection?

I suppose they could install cygwin and run bash, but that seems like overkill
for what should be a simple task.

-Bill
--
Sattre Press The King in Yellow
http://sattre-press.com/ by Robert W. Chambers
in**@sattre-press.com http://sattre-press.com/kiy.html
Oct 31 '08 #10
Bill McClain wrote:
On 2008-10-31, Stef Mientki <st**********@gmail.comwrote:
>Well I don't know any Windows users that still use DOS-boxes ;-)
cheers,

What do they do when they want to run a cross-platform command-line script
with parameters and redirection?

I think it's a slight dig at the nomenclature. Technically,
Windows from NT onwards has had Consoles. (At least, I think
that's what they're called). But lots of people still say
"DOS box" from back in the day.

Architecturally speaking, Windows 3.x (and below) sat on top
of DOS. The Windows NT family was an OS unto itself pretty
much, and provided a Console which sat on top of it.

TJG
Oct 31 '08 #11
On Fri, Oct 31, 2008 at 2:14 PM, Bill McClain
<20******************@spamgourmet.comwrote:
On 2008-10-31, Stef Mientki <st**********@gmail.comwrote:
>Well I don't know any Windows users that still use DOS-boxes ;-)
cheers,

What do they do when they want to run a cross-platform command-line script
with parameters and redirection?

I suppose they could install cygwin and run bash, but that seems like overkill
for what should be a simple task.
Easy. Make a desktop shortcut which includes the parameters, etc.
People do that all the time, including for GUI apps such as Internet
Explorer which have some optional command-line shortcuts.

The only thing you have to do is make sure that the Windows machine
associates files with the .py extensions with the Python interpreter.
The easiest way is to right-click a .py file, select "Choose an
Application," select the Python runtime, and check the box for "always
use this program.
Oct 31 '08 #12
On approximately 10/31/2008 5:06 AM, came the following characters from
the keyboard of Bill McClain:
On 2008-10-31, Glenn Linderman <v+******@g.nevcal.comwrote:
>The problem with stdin/stdout is on Windows 2000 (and maybe the earlier
NT?). But not on XP or AFAIK Vista.

It only occurs when a program is executed indirectly using the file
associations instead of directly via the command line.

File associations, are the Windows "let's do it a different way"
alternative for Unix she-bang lines (#!/path/to/python).
Can you elaborate on this?
What I reported is what I remembered from when XP came out. Seems like

Testing now indicates that it doesn't work so well on XP at this point.

That either means that my memory was faulty, or that some XP update
broke it again.

What I remember for sure, is that this is not a new problem; that it was
introduced in some version of Windows, that it was fixed in some later
version of Windows. The whole issue totally predates Vista, so it would
have had to have been the introduction of 2000 or XP that fixed it. Or
a service pack.

Here is what Google helped me find that M$ remembers:
http://support.microsoft.com/kb/321788 (Ah, I see Tim found this too)

Looks like it was broken in both 2000 and XP, and fix in both via a
service pack or hot fix, but seems to now be broken again?

Creating the registry setting mentioned in this kb article didn't
(immediately) solve the problem. Next time I reboot, I'll try to
remember to test this again.

--
Glenn -- http://nevcal.com/
===========================
A protocol is complete when there is nothing left to remove.
-- Stuart Cheshire, Apple Computer, regarding Zero Configuration Networking

Oct 31 '08 #13
On 2008-10-31, Shawn Milochik <Sh***@milochik.comwrote:
Easy. Make a desktop shortcut which includes the parameters, etc.
People do that all the time, including for GUI apps such as Internet
Explorer which have some optional command-line shortcuts.
The only thing you have to do is make sure that the Windows machine
associates files with the .py extensions with the Python interpreter.
The easiest way is to right-click a .py file, select "Choose an
Application," select the Python runtime, and check the box for "always
use this program.
Ok, trying that...works, but the window doesn't stay open, so we can't see the
results. Any way to do that? Sorry for the Windows-101 tutorial.

DOS box vs Console: I'm sure they use the same icon...

-Bill
--
Sattre Press The King in Yellow
http://sattre-press.com/ by Robert W. Chambers
in**@sattre-press.com http://sattre-press.com/kiy.html
Oct 31 '08 #14
A little bit ago, I wrote:
Creating the registry setting mentioned in this kb article didn't
(immediately) solve the problem. Next time I reboot, I'll try to
remember to test this again.
It occurred to me to create a new CMD Prompt (yes, it is not a "DOS box"
in these versions of Windows) after creating the InheritConsoleHandles
registry value, and it works then.

XP, latest patches.

The old CMD Prompt still fails.

--
Glenn -- http://nevcal.com/
===========================
A protocol is complete when there is nothing left to remove.
-- Stuart Cheshire, Apple Computer, regarding Zero Configuration Networking
Oct 31 '08 #15
On 2008-10-31, Bill McClain <20******************@spamgourmet.comwrote:
Ok, trying that...works, but the window doesn't stay open, so we can't see the
results. Any way to do that? Sorry for the Windows-101 tutorial.
I received an email solution: prepend the shortcut command with "cmd.exe
/k". Works great!

-Bill
--
Sattre Press The King in Yellow
http://sattre-press.com/ by Robert W. Chambers
in**@sattre-press.com http://sattre-press.com/kiy.html
Oct 31 '08 #16
On approximately 10/31/2008 9:22 PM, came the following characters from
the keyboard of Dennis Lee Bieber:
On Fri, 31 Oct 2008 12:14:36 -0700, Glenn Linderman <gl***@nevcal.com>
declaimed the following in comp.lang.python:

>A little bit ago, I wrote:

>>Creating the registry setting mentioned in this kb article didn't
(immediately) solve the problem. Next time I reboot, I'll try to
remember to test this again.
It occurred to me to create a new CMD Prompt (yes, it is not a "DOS box"
in these versions of Windows) after creating the InheritConsoleHandles
registry value, and it works then.

XP, latest patches.

The old CMD Prompt still fails.

A tad confusing -- do you mean the previous console window is
misbehaving, but creating a new console window is working? That behavior
I can believe, as the console probably read the relevant registry
entries on start-up, hence did not see any changes (same thing occurs if
you edit environment variables using My Computer/Properties).
Correct. Creating a new CMD window after making the registry
modification worked, while the CMD window created before the registry
modification continued to fail.
But be careful otherwise... WinXP still has command.com

Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.

C:\DOCUME~1\DENNIS~1>

besides the more modern cmd.exe

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Dennis Lee Bieber>

So "old CMD Prompt" could be mistaken to refer to the ancient
command.com <G>
Indeed it does, and could, but that isn't what I meant. I didn't test
at all with command.com.
--
Glenn -- http://nevcal.com/
===========================
A protocol is complete when there is nothing left to remove.
-- Stuart Cheshire, Apple Computer, regarding Zero Configuration Networking

Nov 1 '08 #17
* Tim Golden (Fri, 31 Oct 2008 12:21:12 +0000)
Bill McClain wrote:
On 2008-10-31, Glenn Linderman <v+******@g.nevcal.comwrote:
This is the MS article which describes the problem:

http://support.microsoft.com/kb/321788

and suggests that it's fixed in XP SP1 but this
thread:

http://mail.python.org/pipermail/pyt...er/506466.html

suggests that maybe it's not.
That article mentions a pipe - and has nothing to do with input or
output redirection...

Thorsten
Nov 1 '08 #18
* Dennis Lee Bieber (Sat, 01 Nov 2008 11:34:32 -0700)
On Sat, 1 Nov 2008 18:50:53 +0100, Thorsten Kampe
<th******@thorstenkampe.dedeclaimed the following in comp.lang.python:
That article mentions a pipe - and has nothing to do with input or
output redirection...
And what is a pipe, at least on Windows command lines, if not a
linked pair of I/O redirection? First program output redirected to <>,
second program input redirected from <(where <represents some
shared data stream which could possibly be implemented by creating a
scratch file in, say %TEMP%\apipe.dat)
In the case of redirection you get the input from or output to a file.
In the case of a pipe you don't have files involved.

Thorsten
Nov 2 '08 #19
On Fri, 31 Oct 2008 18:35:25 +0100, Stef Mientki wrote:
Bill McClain wrote:
>On 2008-10-31, Tim Golden <ma**@timgolden.me.ukwrote:
>>You've got a few options.

Ok, thanks!

It is a small hobbyist community. I'll just document it and tell them
"life is hard for Windows users."
Well I don't know any Windows users that still use DOS-boxes ;-) cheers,
Stef
>-Bill
Well, that is because newer Windows version (NT-family) no longer have
DOS boxes. The "black window" in NT-family Windows are command prompt and
is different from a real DOS box in previous Windows (non-NT-family).
Anyway, I do use command prompts quite regularly, usually for simple
"ping"s and other simple commands like "chkdsk", "defrag", "attrib", etc.
Yes, I do know that each of these have GUI-equivalents.

Nov 3 '08 #20

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

Similar topics

3
by: James | last post by:
Please help - getting very desperate! Sun, 12 October 2003 05:39 I have PHPDEV 4.2.3 from Firepages.com.au as the upgrade to 4.3.0 did not work. I also had an abortive download from PHP.NET as...
1
by: Phillip | last post by:
Hi. I'm having some anoying trouble trying to establish a https connection. I've even switched Python Versions (from 2.2.3 to 2.3.3), but the Errors remain basically the same, allthough they now...
1
by: Matt | last post by:
Hello I have spent the last weeks trying to solve this problem but with no luck at all, I have a piece of code that looks like this declare @bestnr int, @artnr varchar(25), @journalnrrow...
1
by: Hong Kong Expressions | last post by:
My apologies, this is way off-topic.... Im un-employed, looking for employment. The IT market is almost non-existent and jobs are scarce in Arkansas. If you are located in the Arkansas or...
1
by: Hong Kong Expressions | last post by:
My apologies, this is way off-topic.... Im un-employed, looking for employment. The IT market is almost non-existent and jobs are scarce in Arkansas. If you are located in the Arkansas or...
8
by: msnews.microsoft.com | last post by:
I have ADSI code that I can make work at the command line. I cannot in any way get it to work in asp.net. Even using Windows authentication, impersonation on, and providing the credentials...
3
by: garyusenet | last post by:
I have been trying to interface with my act database using .net and act api's. I was originally using c# but it wouldn't connect to the database. I tried VB in desperation and it is connecting! ...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
2
by: begoddendave | last post by:
Hi I am desperate for some help. I have a very simple piece of code that doesn't work. I request a number from the query string I request a number from a database (MS Access) If one is...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
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
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...
0
tracyyun
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 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.