Liconverter/mokucli

Dear supporters, I use data logger for data acquisition. I can download the .li file, but I can not convert it using the given methods! What I hope to have is a line of code in jupyter notebook, which convert the .li file to .csv for me using the given mokucli or … But for me it was hard to understand how to run or use the mokucli after downloading the .tar file. Can you please give me a better explanation of this, such that I can convert the .li to .csv using python code in jupyter notebook?

Hi Saman,

Would you mind sharing your code that is not working for you so that I can understand what is not working in this process?

To convert a file using mokucli I use the following line to convert the downloaded .li binary file to a csv:

mokucli convert FILENAME.li --format=csv

However this may not be the best way to convert the file if you are trying to script this process, as mokucli is designed to be used as a commandline tool, not used in a jupyter notebook. If you are trying to script or automate your logged data then you may want to try the Python API, specifically the Data Logger’s stream_to_file function, which will stream the data and save it to a file type of your choice. You can find more details on the API Reference, but here is an example of how to stream the data to a csv file:

from moku.instruments import Datalogger
i = Datalogger('IP.ADD.R.ESS')
i.start_streaming(duration = 10)
i.stream_to_file('csv')

Thank you for your quick respond. Below is the code I am using to acquire data using stream_to_file:

from moku.instruments import Datalogger
i = Datalogger(‘IP_Adresse’, force_connect=True)

try:
i.set_frontend(channel=2, impedance=‘1MOhm’, coupling=“DC”, range=“10Vpp”)
i.set_samplerate(200)
i.set_acquisition_mode(mode=‘Precision’)
logFile = i.start_streaming(duration=10)
complete = False
while not complete:
time.sleep(0.5)
progress = i.logging_progress()
complete = progress[‘complete’]
i.download(“media”, logFile[‘file_name’], os.path.join(os.getcwd(), logFile[‘file_name’]))
i.stream_to_file(‘csv’)
print(“Downloaded log file to local directory.”)

except Exception as e:
print(f’Exception occurred: {e}')
finally:
i.relinquish_ownership()

I downloaded and installed mokucli for linux. Installed it and added it to the PATH. But I get this error when running the above code:
Exception occurred: [Errno 13] Permission denied: ‘/home/gw170817/Downloads/mokucli-linux/mokucli-linux-2.2.2’

Hi Saman,

Sorry that this response was not so quickly.

I think this code below might work for you. Your code above used i.logging_progress() but this is for file logging not streaming. Instead I’ve used i.get_stream_status() to track the streaming status and have altered your while look to track this variable.

You also do not need to use i.download() as you are streaming directly to file, meaning there is nothing saved to the Moku to download.

import time

from moku.instruments import Datalogger
i = Datalogger('10.1.119.221', force_connect=True)

try:
	i.set_frontend(channel=2, impedance='1MOhm', coupling="DC", range="40Vpp")
	i.set_samplerate(200)
	i.set_acquisition_mode(mode='Precision')

	logFile = i.start_streaming(duration=10)
	i.stream_to_file()
	complete = False
	while complete != 'COMPLETED':
		time.sleep(0.5)
		progress = i.get_stream_status()
		complete = progress['status']
	print("Downloaded log file to local directory.")

except Exception as e:
	print(f'Exception occurred: {e}')
finally:
	i.relinquish_ownership()

Let me know how this goes.