import sys
import json

# first command line arg: filename to open
# second command line arg: filename to write (NOT the same)
if sys[1] == sys[2]:
	print "Don't overwrite your file! Please run again."
elif sys[2][-4:].upper() != "JSON":
	print "Please save input in a JSON file." # quick and easy conversion
else:
	f = open(sys[1],"r")
	lines = f.readlines()
	f.close()
	tab_split = []
	for l in lines:
		sep = lines.split("\t")
		tab_split.append(sep)

	d = {}
	d["maxwt"] = tab_split[0][-1]
	d["items"] = {}

	for inp in tab_split[2:]:
		d["items"][inp[0]] = {}
		d["items"][inp[0]]["weight"] = inp[1]
		d["items"][inp[0]]["value"] = inp[2]

	jsonf = open(sys[2],"w")
	jsonf.write(json.dumps(str(d)))

@@ -126,16 +126,21 @@
 )%0Aif sys
+.argv
 %5B1%5D == s
@@ -141,16 +141,21 @@
 %5D == sys
+.argv
 %5B2%5D:%0A%09pr
@@ -213,16 +213,21 @@
 elif sys
+.argv
 %5B2%5D%5B-4:%5D
@@ -336,16 +336,21 @@
 open(sys
+.argv
 %5B1%5D,%22r%22)
@@ -426,20 +426,16 @@
 %09sep = l
-ines
 .split(%22
@@ -439,16 +439,29 @@
 t(%22%5Ct%22)%0A
+%09%09#print sep%0A
 %09%09tab_sp
@@ -561,16 +561,28 @@
 it%5B2:%5D:%0A
+%09%09print inp%0A
 %09%09d%5B%22ite
@@ -636,14 +636,19 @@
 %5D = 
+int(
 inp%5B1%5D
+)
 %0A%09%09d
@@ -682,12 +682,25 @@
 = in
-p%5B2%5D
+t(inp%5B2%5D.strip())
 %0A%0A%09j
@@ -714,16 +714,21 @@
 open(sys
+.argv
 %5B2%5D,%22w%22)
@@ -756,13 +756,8 @@
 mps(
-str(d)
+d
 ))%0A

fix bugs in convert tab data fxn