Downloading data in a date and time range
The following script will download data from instrument. The script includes a date
and time range, file duration (minutes), as well as the directory that the files are
saved to, all of which can be modified to suit your needs. This program uses the
Python
requests
libraries, so we'll begin by installing those.
1
Install the
requests
libraries.
Launch a terminal on Mac or command prompt on Windows. Type
pip install
requests
or
sudo pip install requests
in the command line tool. The ter-
minal will issue a few replies indicating success.
2
Create the python script to save the data.
Copy the following into a text file and save it to your computer's desktop (or
another directory) with a
.py
extension, like
import-datetime.py
.
import
datetime
import
requests
import
socket
slno =
'tgXX-01009.local'
ip = socket.
gethostbyname
(slno)
dl1 =
"http://"
+ ip+
":8080/ExportAdvancedData?tmin="
dl2 =
"&tmax="
tmz =
"-06:00"
dt = datetime.
datetime
(
2019
,
5
,
10
,
0
,
0
,
0
)
end = datetime.
datetime
(
2019
,
5
,
11
,
0
,
0
,
0
)
step = datetime.
timedelta
(minutes=
30
)
fls = []
ts5= []
while
dt <= end:
ts1 = dt.
strftime
(
'%Y-%m-%d %H:%M:%S'
)
ts3 = dt.
strftime
(
'%Y-%m-%d %H-%M-%S'
)
ts2 = ts1[
0
:
10
] +
"T"
+ts1[
11
:]
ts4 = ts1[
0
:
10
] +
"T"
+ts3[
11
:] +
".txt"
;
ts5.
append
(ts4)
fls.
append
(ts2)
dt += step
(fls)
for
i
in
range
(
0
,
len
(fls)-
1
,
1
):
Section 7. Communication with the MQTT protocol
7-9
Downloading data in a date and time range
Summary of Contents for LI-7815
Page 1: ...LI 7815 CO2 H2O Trace Gas Analyzer Instruction Manual...
Page 2: ......
Page 10: ...viii...
Page 30: ...Section 2 Getting started 2 14 LI 7815 CO H O Gas Analyzer...
Page 38: ...Section 3 Applications of the LI 7815 3 8 LI 7815 CO H O Gas Analyzer...
Page 42: ...Section 4 Software overview 4 4 LI 7815 CO H O Gas Analyzer...
Page 54: ...Section 4 Software overview 4 16 LI 7815 CO H O Gas Analyzer...
Page 62: ...Section 5 Troubleshooting 5 8 LI 7815 CO H O Gas Analyzer...
Page 70: ...Section 6 Maintenance 6 8 LI 7815 CO H O Gas Analyzer...
Page 88: ...Appendix B Additional safety information B 6 LI 7815 CO H O Gas Analyzer...
Page 92: ...Appendix C Specifications C 4 LI 7815 CO H O Gas Analyzer...
Page 97: ......