[OSM-talk] k/v for import of list of gas stations of France?

Marcus Bauer marcus.bauer at gmail.com
Mon Jan 8 23:03:30 GMT 2007


On Mon, 2007-01-08 at 22:16 +0100, Petter Reinholdtsen wrote:
> [Marcus Bauer]
> > Fred has a csv list of +1000 gas stations in France.
> >
> > I wrote a small perl script to convert them into a .osm file. Before
> > importing such a large number my questions is whether the following tags
> > make sense:
> 
> This is very cool.  In December 2005 we got a donation of several
> points of interest (lodging, aktivities, el-shops) for Norway in CSV
> format.  No-one have imported it yet, as far as I can tell.
> Check
> <URL:http://lists.openstreetmap.org/pipermail/talk/2005-December/001772.html>.
> 
> Any chance your script can read these files too?
> 
> Friendly,


It's just some lines of perl. You have to adjust it for your csv. If you
need further help, simply drop me a line.

You should test your output with xmlstarlet. 
"xmlstarlet val mydata.osm"

Marcus

Note: I am not sure if the encoding iso-8859-1 works with josm. Thus
especially check in josm if the characters are what you want to have
before uploading.

------------------------------------------------------------------

#!/usr/bin/perl
# converter.pl
# usage: converter.pl < mydata.csv > mydata.osm

print "<?xml version='1.0' encoding='iso-8859-1'?>\n";
print "<osm version='0.3' generator='JOSM'>\n\n";


$i = 0;

while(<STDIN>)
{
	$i--;

	# split the csv into an array 
	@result = split(';', $_);

	$name		= $result[0];
	$address	= $result[1];
	$postal_code	= $result[2];
	$is_in		= $result[3];


	$lat = $result[4];
	$lon = $result[5];

	$info = $result[6];

	print "<node id='$i' lat='$lat' lon='$lon' >\n";

	print "\t<tag k='amenity' v='fuel' />\n";
	print "\t<tag k='name' v=\"$name\" />\n";
	print "\t<tag k='address' v=\"$address\" />\n";
	print "\t<tag k='postal_code' v='$postal_code' />\n";
	print "\t<tag k='is_in' v=\"${is_in}, France\" />\n";
	print "\t<tag k='created_by' v='stationsgpl_convert.pl'/>\n";
	print "\t<tag k='info' v=\"$info\" />\n";

	print "</node>\n";

	#print $_;
}



print "</osm>\n";






More information about the talk mailing list