u:\20-birdy> tweet.py "Hello World!"
Here's the script (tweet.py):
u:\20-birdy> tweet.py "Hello World!"
Here's the script (tweet.py):
Of course, inquiring minds want to know, so I wrote a little script (account_info.py). The script takes one argument: the name of a twitter account. In the following screenshot, I read some account data for the account twitterapi:
For example, the script reports that twitterapi has 5.3 million followers, but follows only 48 other accounts.
The script is also able to read the current status. For a reason I don't understand, the status for twitterapi seems always to be "@TheNiceBot aww thanks, you're lovely too! :-)". The status is correct, however, for other accounts.
Here's the script
These ways are kept in a specific table:
With this table, I can now extract the lattitude/longitude pairs for each node in the relevant ways and write them into a kml file.
The algorithm basically boils down to:
Here's a screen shot of the result:
OpenStreetMap: convert an pbf to an sqlite database with Python
OSMNode, OSMWay and OSMRelation (see the
source at github).protoc.exe. After extracting this file, the environment variable PATH should be changed so that
it points to the directory with protoc.exe.
For the python installation, the full source protobuf-2.5.0.tar.bz2
is also needed. After extracting them, cd into the python directory and execute:
OpenStreetMap: convert an pbf to an sqlite database with Python
python -m SimpleHTTPServer
This command creates a webserver that listens on port 8000, so that it can be accessed with a browser on localhost:8000
python -m SimpleHTTPServer 7777
sqlite3 module in Python:
import sqlite3
import os.path
if os.path.isfile('foo.db'):
os.remove('foo.db')
db = sqlite3.connect('foo.db')
cur = db.cursor()
cur.execute('create table bar (a number, b varchar)')
cur.execute("insert into bar values (2, 'two')")
cur.execute('insert into bar values (?, ?)', (42, 'forty-two'))
cur.executemany('insert into bar values (?, ?)', [
(4, 'four'),
(5, 'five'),
(7, 'seven'),
(9, 'nine')
])
for row in cur.execute('select * from bar order by a'):
print "%2d: %s" % (row[0], row[1])
col 1,col 2,col 3
foo,bar,baz
one,two,three
42,,0
import csv
csv_file = open('data.csv', 'r')
csv_reader = csv.reader(csv_file)
header = csv_reader.next()
for record in csv_reader:
print 'Record:'
i = 0
for rec_value in record:
print ' ' + header[i] + ': ' + rec_value
i += 1