-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrPyO.py
More file actions
47 lines (37 loc) · 1.26 KB
/
rPyO.py
File metadata and controls
47 lines (37 loc) · 1.26 KB
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
import OriginExt as origin
import os, os.path
import csv
import pandas as pd
import sys
import glob
app = origin.Application()
app.Visible = 1
root = sys.argv[1]
print(sys.argv[1])
cells = [d for d in os.listdir(root) if os.path.isdir(os.path.join(root, d))]
for cell in cells:
if cell[:7] != "Channel":
cells.remove(cell)
files = [d for d in os.listdir(root) if os.path.isfile(os.path.join(root, d))]
os.chdir(root)
files = glob.glob('*.{}'.format('csv'))
proj = app.CreatePage(app.OPT_WORKSHEET, "SummaryData")
wbook = app.Pages(proj)
for i in files:
tmpData = pd.read_csv(root + "/" + i, header=0, encoding = "ISO-8859-1")
wks = wbook.Layers.Add(i)
wks.SetCols(tmpData.shape[1])
for n, name in enumerate(tmpData.columns):
col = wks.Columns(n)
col.LongName = tmpData.columns[n]
col.SetData(tmpData[name].values)
proj = app.CreatePage(app.OPT_WORKSHEET, "Cells-FullData")
wbook = app.Pages(proj)
for i in cells:
tmpData = pd.read_csv(root + "/" + i + "/" + i + ".csv", header=0, encoding = "ISO-8859-1")
wks = wbook.Layers.Add(i)
wks.SetCols(tmpData.shape[1])
for n, name in enumerate(tmpData.columns):
col = wks.Columns(n)
col.LongName = tmpData.columns[n]
col.SetData(tmpData[name].values)