Files
Misc-Downhole-Diagnostics/readCardFile.py
Patrick McDonagh a1714c722f Initial Commit
2016-07-01 16:43:39 -05:00

36 lines
912 B
Python

__author__ = 'patrickjmcd'
import Tkinter as tk
import tkFileDialog as fd
def readFile(file=None):
surface = []
downhole = []
if not file:
tk.Tk().withdraw()
file_path = fd.askopenfilename()
else:
file_path = file
storeSurface = False
storeDownhole = False
import csv
with open(file_path, 'r') as csvfile:
dataReader = csv.reader(csvfile)
for row in dataReader:
if storeDownhole:
downhole.append((float(row[0]),float(row[1])))
if row[0]=="d_pos":
storeSurface = False
storeDownhole = True
if storeSurface:
surface.append((float(row[0]),float(row[1])))
if row[0]=="s_pos":
storeSurface = True
storeDownhole = False
return [surface, downhole]
# if __name__ == "__main__":
# readFile()