Skip to content

Commit

Permalink
created simple python ETL for importing item attribs.. will probably …
Browse files Browse the repository at this point in the history
…stay part of core package once made generic and more robes
  • Loading branch information
elliottcordo committed Mar 16, 2014
1 parent 81dcf31 commit bbb990d
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions rpm/item_import.py
@@ -0,0 +1,35 @@
#simple script for importing u_iem

import redis
import sys

from config import Config


#config
cfg = Config()

#redis connect (pipeline)
rC = redis.Redis(cfg.g('redis','host'))
pL = rC.pipeline(cfg.g('redis','port'))


#read file
itemfile = "/Users/elliottcordo/Projects/Caserta/rpM/sample_data/movie_lens/u_item.txt" # str(sys.argv)
items = open (itemfile)

#read the lines
records = items.readlines()

#loop split and write to redis
for line in records:
#print line
parsed_line = line.split('|')
#print parsed_line[0]+ ' name ' + parsed_line[1]
pL.hset ('I'+str(parsed_line[0]),'name', parsed_line[1])
pL.hset ('I'+str(parsed_line[0]),'imdb', parsed_line[4])


pL.execute()

items.close()

0 comments on commit bbb990d

Please sign in to comment.