Skip to content

Instantly share code, notes, and snippets.

@Pengor
Created April 8, 2015 03:27
Show Gist options
  • Save Pengor/b68382d32c63772464b9 to your computer and use it in GitHub Desktop.
Save Pengor/b68382d32c63772464b9 to your computer and use it in GitHub Desktop.
Converts iterated data to timed data. For use with OpenBCI output files.
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("in_file", type=str)
parser.add_argument("out_file", type=str)
args = parser.parse_args()
inFile = open(args.in_file,'r')
outFile = open(args.out_file,'w')
for index, line in enumerate(inFile):
if not '%' in line:
lineTime = (index - 5) * 0.000015625 # 2nd value is 1/(250 Hz * 256 cycles)
writeString = str('%8.9f' % lineTime) + line[line.find(","):]
outFile.write(writeString)
inFile.close()
outFile.close()
print("File",args.in_file,"converted to",args.out_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment