NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum


I would like to fix simple mistakes in the opening_hours tag based on regular expressions but only if it is clear what they mean … One example (second example on the key page) is opening_hours=0600-1800 → opening_hours=06:00-18:00.

An example Python script looks like this:

#!/usr/bin/env python
# encoding: utf-8

import re

wrong = '1200-2300'

regex = re.compile(r'\A(?P<start_hour>[0-1][0-9]|2[0-4])(?P<start_min>[:1-5][0-9]|0[0-9])\s*(?P<sep>-)\s*(?P<end_hour>[0-1][0-9]|2[0-4])(?P<end_min>[:1-5][0-9]|0[0-9])\Z')

re_object =, wrong)
bot_right_val = '%s:%s%s%s:%s' % ('start_hour'),'start_min'),'sep'),'end_hour'),'end_min')
print '%s -> %s' % (wrong, bot_right_val)

I would like to automate this task a little bit more to avoid chancing this by hand. How can I integrate this script to JOSM? I can already load all wrong values matching this regex with in JOSM.

asked 02 Mar '14, 15:11

ypid's gravatar image

accept rate: 0%


Just in case you do not know it yet: Automated Edits code of conduct. Your idea sounds like this applies.

(02 Mar '14, 15:45) aseerel4c26 ♦

@aseerel4c26 I already read this page. Thanks for the hint. The problem is that I did not really find a description about how to do it. I thought about writing a Xybot rule file but I wanted to test this first in a simple way.

(02 Mar '14, 15:53) ypid

The only 'simple' way I came up with is to download all occurrences of a tag in JOSM, save the .osm file, parse and change the file, load the file back to JOSM, upload the file.

(02 Mar '14, 15:55) ypid

Okay, fine. So, before you are doing large scale edits, please discuss them (not on this help site).

(02 Mar '14, 15:56) aseerel4c26 ♦

JOSM has a scripting plugin which supports scripts of various languages. The quality assurance script is a great example for this interface.

permanent link

answered 02 Mar '14, 16:36

scai's gravatar image

scai ♦
accept rate: 23%

edited 02 Mar '14, 16:43

aseerel4c26's gravatar image

aseerel4c26 ♦

this sounds like the better way. ;-)

(02 Mar '14, 16:40) aseerel4c26 ♦

Thanks. I might check that out in detail later. For now I will go with the .osm file script variant because I feel more confident in this area.

(02 Mar '14, 16:48) ypid

if you want to use JOSM, my newbie and basic idea (this may be the worst possible way) would be to edit a .osm/JOSM file:

  1. Download the data into a .osm file
  2. change the file with your script (just look into a .osm file which contains changes made by JOSM to see how JOSM saves changes - or see the format description, link above)
  3. open and upload with JOSM
permanent link

answered 02 Mar '14, 15:53

aseerel4c26's gravatar image

aseerel4c26 ♦
accept rate: 18%

edited 02 Mar '14, 16:04

I guess this is the way to go.

(02 Mar '14, 15:57) ypid

Started to write the script:

(02 Mar '14, 16:48) ypid

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 02 Mar '14, 15:11

question was seen: 4,330 times

last updated: 02 Mar '14, 16:48

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum