Created
April 8, 2015 03:27
-
-
Save Pengor/b68382d32c63772464b9 to your computer and use it in GitHub Desktop.
Converts iterated data to timed data. For use with OpenBCI output files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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