annotate sparql.py @ 4:8c7a1b951bb3 draft

Uploaded
author sem4j
date Wed, 25 Sep 2013 02:38:39 -0400
parents dba28145ab27
children 2c9827b61b71
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
dba28145ab27 Uploaded
sem4j
parents:
diff changeset
1 # sparql.py version:0.1
dba28145ab27 Uploaded
sem4j
parents:
diff changeset
2 # USAGE: python sparql.py <str_select> <input_file> <output_file>
dba28145ab27 Uploaded
sem4j
parents:
diff changeset
3
dba28145ab27 Uploaded
sem4j
parents:
diff changeset
4 import sys, os, commands
dba28145ab27 Uploaded
sem4j
parents:
diff changeset
5
dba28145ab27 Uploaded
sem4j
parents:
diff changeset
6 argvs = sys.argv
dba28145ab27 Uploaded
sem4j
parents:
diff changeset
7 if (len(argvs) != 4):
dba28145ab27 Uploaded
sem4j
parents:
diff changeset
8 print 'Number of argv is incorrect'
dba28145ab27 Uploaded
sem4j
parents:
diff changeset
9 quit()
dba28145ab27 Uploaded
sem4j
parents:
diff changeset
10
dba28145ab27 Uploaded
sem4j
parents:
diff changeset
11 out = open('query.tmp', 'w')
dba28145ab27 Uploaded
sem4j
parents:
diff changeset
12 out.write(argvs[1])
dba28145ab27 Uploaded
sem4j
parents:
diff changeset
13 out.close()
dba28145ab27 Uploaded
sem4j
parents:
diff changeset
14
dba28145ab27 Uploaded
sem4j
parents:
diff changeset
15 os.system('mv ' + argvs[2] + ' ' + argvs[2] + '.nt')
dba28145ab27 Uploaded
sem4j
parents:
diff changeset
16 stdout = commands.getoutput('/Users/Ryota/Softwares/jena/apache-jena-2.11.0/bin/sparql --query=query.tmp --data=' + argvs[2] + '.nt -results=TSV')
dba28145ab27 Uploaded
sem4j
parents:
diff changeset
17 os.system('mv ' + argvs[2] + '.nt ' + argvs[2])
dba28145ab27 Uploaded
sem4j
parents:
diff changeset
18
dba28145ab27 Uploaded
sem4j
parents:
diff changeset
19 out = open(argvs[3], 'w')
dba28145ab27 Uploaded
sem4j
parents:
diff changeset
20 out.write(stdout)
dba28145ab27 Uploaded
sem4j
parents:
diff changeset
21 out.close()