Commit f909fc20 authored by Zhukov, Alexander P's avatar Zhukov, Alexander P
Browse files

Started work on saving in binary format

parent 3a87579a
No preview for this file type
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 30 14:09:25 2020
@author: az9
"""
from datetime import datetime as dt
def convert_line(name,csv):
timestamp = dt.strptime(csv[0], "%I:%M:%S.%f %p %m/%d/%Y")
result = []
pv_name = name+':xAvg'
data = float(csv[1])
result.append({'timsetamp': timestamp, 'name': pv_name, 'data': data})
return result
# result[name+':yAvg'] = csv[2]
# result[name+':phaseAvg'] = csv[3]
# result[name+':ampAvg'] = csv[4]
# num = int(csv[5])
file = open('/data/BinStorage/BPMDataRaw/2019_08_06__06-20-41_520-SCL_Diag-BPM00a.csv','r')
gen = (x.split(',') for x in file)
gen.__next__()
data = [x for x in gen]
print(convert_line('SCL_Diag:BPM00a',data[1]))
file.close()
\ No newline at end of file
......@@ -9,12 +9,7 @@ Created on Mon Jan 27 16:14:52 2020
from read_storage import BinaryStorage
# file = open('/data/BinStorage/test.bin','rb')
# bytes = file.read(12)
# print(bytes.decode())
file = BinaryStorage('/data/BinStorage/test.bin')
print(file[0::2])
print(file[0:10:2])
file.close()
\ No newline at end of file
......@@ -10,17 +10,19 @@ from datetime import datetime as dt
import os
HEADER_SZ=12
class BinaryStorage:
HEADER_SZ=12
def __init__(self, path):
self.file = open('/data/BinStorage/test.bin','rb')
bytes = self.file.read(BinaryStorage.HEADER_SZ)
bytes = self.file.read(HEADER_SZ)
# print(bytes.decode())
self.rec_table = BinaryStorage.read_epilog(self.file)
self.file.seek(BinaryStorage.HEADER_SZ)
self.file.seek(HEADER_SZ)
def close(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment