-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vernier_to_CSV.py
50 lines (35 loc) · 1.01 KB
/
Vernier_to_CSV.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# -*- coding: utf-8 -*-
import csv
inPath = str(input("Path to input txt file?: "))
outPath = str(input("Path to output csv file?: "))
class csvFile:
def open(self, path):
csvFile = open(path, "w")
return (csvFile)
def writeRow(self, csvFile, rowText=str(), splitter=str()):
writer = csv.writer(csvFile)
rowArray = rowText.split(splitter)
rowToWrite = []
for eachElement in rowArray:
rowToWrite.append(eachElement)
writer.writerow(rowToWrite)
class txtFile:
def open(self, path):
txtFile = open(path, "r")
return (txtFile)
def parse():
splitter = "\t"
unitLine = 6
dataStartLine = 8
inp = txtFile()
inputFile = inp.open(inPath)
out = csvFile()
outputFile = out.open(outPath)
i = int(0)
for eachLine in inputFile:
i += 1
if (i == unitLine) or (i >= dataStartLine):
out.writeRow(outputFile, eachLine, splitter)
inputFile.close()
outputFile.close()
parse()