How-To Guide
Log iTrixx Data to a CSV File Automatically
Save a reading from your iTrixx device to a CSV file every hour on a Windows computer, with a short Python script and Windows Task Scheduler. No programming experience needed.
01Before You Start
A small Python script reads your iTrixx device’s data (in JSON format) and adds it as a new row to a CSV file, with the date and time. Windows Task Scheduler runs the script every hour. You can open the CSV file in Excel at any time.
Supported Devices
| Device | JSON address |
|---|---|
| iTrixx-WFMN | http://192.168.1.50 |
| iTrixx-Ultra-NHM, Ultra 300 and eIO-RTU | http://192.168.1.50:30000 |
Replace 192.168.1.50 with your device’s IP address. You can find it with the free Discover program.
Open the JSON address in your browser first. If you see text with the device’s data, the address is right.
What You Need
- A Windows computer that stays on, or can wake from sleep.
- The iTrixx device on the same network as the computer.
- Internet access, only for downloading Python and the
requestsadd-on.
02Step 1: Install Python
- Go to python.org/downloads and download the latest version for Windows.
- Run the installer. On the first screen, check Add python.exe to PATH.
- Click Install Now and finish the installation.
- Open Command Prompt and check the version:
It should show a version such as Python 3.14.2. If it doesn’t, restart the computer and try again.
- Install the
requestsadd-on, which the script uses to read the device:
03Step 2: Create the Script
- In File Explorer, create a folder named C:\iTrixx_logger.
- Open Notepad and paste the code below (use the Copy button).
- On the
URL =line, replace the address with your device’s JSON address from the table above. Keep the quotes. - Click File › Save As, open the C:\iTrixx_logger folder, set Save as type to All Files, enter the name fetch_json.py and click Save.
import csv
import os
from datetime import datetime
import requests
# Your device's JSON address (see the Supported Devices table)
URL = "http://192.168.1.50:30000"
# The CSV file is saved in the same folder as this script
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
CSV_FILE = os.path.join(SCRIPT_DIR, "data_log.csv")
def main():
response = requests.get(URL, timeout=10)
response.raise_for_status()
data = response.json()
if isinstance(data, dict):
data = [data]
timestamp = datetime.now().isoformat(timespec="seconds")
for row in data:
row["timestamp"] = timestamp
file_exists = os.path.isfile(CSV_FILE)
with open(CSV_FILE, "a", newline="", encoding="utf-8") as f:
writer = csv.DictWriter(f, fieldnames=data[0].keys())
if not file_exists:
writer.writeheader()
writer.writerows(data)
if __name__ == "__main__":
main()
Set Save as type to All Files. Otherwise Notepad saves the file as fetch_json.py.txt and it won’t run. In File Explorer the file should show as Python Script.
04Step 3: Test the Script
- In Command Prompt, go to the folder:
- Run the script:
- If nothing is printed, it worked. The folder now has a file named data_log.csv.
- Open data_log.csv in Excel. It has a row of data with a timestamp column at the end. Each time the script runs, it adds a row.
Values that contain a list, such as all the meters or inputs, are saved together in one cell, as in Figure 3.
05Step 4: Run It Every Hour
First find the full path of Python, which Task Scheduler needs. In Command Prompt, run:
Copy the first path it shows, for example C:\Users\you\AppData\Local\Programs\Python\Python314\python.exe.
Then create the task:
- Open Task Scheduler (search the Start menu, or run
taskschd.msc) and click Create Task. - Fill in each tab as shown in the table below, then click OK. Enter your Windows password if asked.
- To test it, right-click the task in the list and choose Run. A new row appears in data_log.csv.
| Tab | Setting |
|---|---|
| General | Name: iTrixx logger. Select Run whether user is logged on or not. |
| Triggers | Click New. Begin the task: On a schedule, Daily. Check Repeat task every: 1 hour, for a duration of: Indefinitely. |
| Actions | Click New, choose Start a program. Program/script: the Python path from where pythonAdd arguments: fetch_json.pyStart in: C:\iTrixx_logger |
| Conditions | Uncheck Start the task only if the computer is on AC power. Check Wake the computer to run this task. |
| Settings | Check Allow task to be run on demand and Run task as soon as possible after a scheduled start is missed. |
The CSV file now gets a new row every hour, also when the laptop runs on battery or wakes from sleep.
To check it faster, set Repeat task every to 5 minutes for a while, then set it back to 1 hour.
06Troubleshooting
- The script shows an error when run by hand: check the address on the
URL =line, and open it in a browser to make sure the device can be reached. - “python” is not recognized: Python wasn’t added to PATH. Reinstall it with Add python.exe to PATH checked.
- “No module named requests”: run
python -m pip install requestsagain. - No data_log.csv is created: check that the file is named fetch_json.py, not fetch_json.py.txt.
- The task doesn’t run: check the Python path in Program/script, the Start in folder, and the wake and power settings on the Conditions tab. The Last Run Result column in Task Scheduler shows 0x0 when it worked.
- The CSV looks wrong: open the JSON address in a browser to see what the device sends. If you change devices, rename or delete data_log.csv first, so the columns start fresh.
Still stuck? Contact Linortek tech support or call 336-485-6199.
Still stuck? Our support team can help with setup and configuration.
