2
|
1 # sparql.py version:0.1
|
|
2 # USAGE: python sparql.py <str_select> <input_file> <output_file>
|
|
3
|
|
4 import sys, os, commands
|
|
5
|
|
6 argvs = sys.argv
|
|
7 if (len(argvs) != 4):
|
|
8 print 'Number of argv is incorrect'
|
|
9 quit()
|
|
10
|
|
11 out = open('query.tmp', 'w')
|
|
12 out.write(argvs[1])
|
|
13 out.close()
|
|
14
|
|
15 os.system('mv ' + argvs[2] + ' ' + argvs[2] + '.nt')
|
9
|
16 stdout = commands.getoutput('sparql --query=query.tmp --data=' + argvs[2] + '.nt -results=TSV')
|
2
|
17 os.system('mv ' + argvs[2] + '.nt ' + argvs[2])
|
|
18
|
|
19 out = open(argvs[3], 'w')
|
|
20 out.write(stdout)
|
|
21 out.close()
|