Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created simple python ETL for importing item attribs.. will probably …
…stay part of core package once made generic and more robes
- Loading branch information
1 parent
81dcf31
commit bbb990d
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |