Revision as of 03:15, 3 April 2008 by Jinha (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
  1. !/usr/bin/python
  1. Syntax: convert.py inputFile nData nFeature nOutput

import sys import string import Numeric

  1. Open input file

inFile = open(sys.argv[1], 'r')

  1. Print out the first line

print sys.argv[2], sys.argv[3], sys.argv[4]

for line in inFile:

   # Initialize feature vector to all zero
   feature = Numeric.zeros(int(sys.argv[3]))
   sline = string.split(line)
   # Iterate through and update the value for the feature
   for num in sline[2:]:
       snum = string.split(num,":")
       feature[int(snum[0])-1] = float(snum[1])
   # Print out the feature vector
   for a in feature:
       print a,
   # Print out the output
   print
   print sline[0]
  1. Close file

inFile.close()

Alumni Liaison

Sees the importance of signal filtering in medical imaging

Dhruv Lamba, BSEE2010