Mercurial > hg > drupalISMI
comparison importFromOpenMind/converter/addDRI.py @ 0:124ef8f3b22d
initial
author | Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de> |
---|---|
date | Fri, 27 Mar 2015 19:21:42 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:124ef8f3b22d |
---|---|
1 from urllib import request | |
2 | |
3 class converter: | |
4 | |
5 out ="/var/tmp/out.csv" | |
6 url = "http://md.mpiwg-berlin.mpg.de/purls/search?q=" # /permanent/library/W028ATN3 | |
7 def read(self,fn): | |
8 | |
9 of = open(self.out,"w") | |
10 | |
11 fl = open(fn,"r") | |
12 | |
13 for line in fl.readlines(): | |
14 line = line.replace("\n","") | |
15 line = line.replace('"','') | |
16 splitted = line.split(",") | |
17 | |
18 path = splitted[0].replace('"','') | |
19 path = path.replace("/mpiwg/online","") | |
20 | |
21 qr = self.url + path | |
22 | |
23 g = request.urlopen(qr, data=bytearray(path,"utf-8")) | |
24 | |
25 p = g.read().decode('utf-8') | |
26 | |
27 spl = p.split("\t") | |
28 | |
29 if len(spl) > 1: | |
30 dri = spl[1] | |
31 | |
32 splitted.append(dri) | |
33 | |
34 print (splitted) | |
35 | |
36 of.write(",".join(splitted)+"\n") | |
37 | |
38 | |
39 of.close() | |
40 | |
41 | |
42 | |
43 | |
44 cv =converter() | |
45 | |
46 cv.read("/var/tmp/archive.csv") | |
47 | |
48 | |
49 |