import sys
import livewire
from csvutils import write_csv

# csvcut -c 3 livewire_events.csv | sort | uniq > livewire_venueid.txt
# cat livewire_venueid.txt | xargs python scrape_venues.py 

if __name__ == '__main__':
  venues = []
  for venueid in sys.argv[1:]:
    print venueid
    venue = livewire.parse_venue(venueid)
    if 'links' in venue:
      venue['venuepage_label'] = venue['links'][0]['label']
      venue['venuepage_href'] = venue['links'][0]['href']
    else:
      venue['venuepage_label'] = ''
      venue['venuepage_href'] = ''
    venues.append(venue)
  write_csv('livewire_venues.csv',venues,'name','url','venuepage_label','venuepage_href','street-address','locality','region','phone','mail','postal-code','lat','lon')
Exemple #2
0
def write_events(events):
  write_csv('events.csv',events,'name','venue','venue_url','date')
import json
import csvutils
import codecs
import nolaflickr

if __name__ == '__main__':
  f = codecs.open('artists.txt','r','utf-8')
  all_authors = []
  for l in f:
    all_authors.append(l.strip())
  data = json.load(open('artist_info.json','r'))
  for a in data:
    name = a['name']
    a['summary'] = a.get('bio_summary','')
    a['image'] = a.get('image_large','')
    a['image_attrib'] = a.get('url','')
    a['livewire_id'] = a.get('mbid','')
    if name in all_authors:
      all_authors.remove(name)
  for name in all_authors:
    author = dict(name=name)
    flickr = nolaflickr.find_flickr_image(name)
    if flickr:
      author['image_attrib'] = flickr[0]
      author['image'] = flickr[1]
    data.append(author)
  data.sort(key=lambda x:x['name'])
  csvutils.write_csv('artists.csv',data,'name','tags','summary','url','livewire_id','image','image_attrib')
def write_events(events):
  print events
  write_csv('livewire_events.csv',events,'name','venue','venueid','venue_url','venueid','date')