Quantcast
Channel: All Developer posts
Viewing all articles
Browse latest Browse all 48084

Python formatting for streaming dataset -formatting question

$
0
0

Alright, so I am not a developer by trade, but a windows infrastructure admin.  I dabble in electronics and automation, and have been doing odd experiments with Rpi and Arduino components for a couple of years now.   Only recently have I explored taking the realtime data I can collect and bundling it together for a practical purpose - and am exploring PowerBI as a method to visualize.

 

Long story short, I have a Rpi pulling data from an Arduino, temp, humidity, voltage and current information.  I'm following this guide on how to get started, and I am failing to understand the python formatting being done.  

https://powerbi.microsoft.com/en-us/blog/using-power-bi-real-time-dashboards-to-display-iot-sensor-data-a-step-by-step-tutorial/ -- the only difference is i am not rewiring existing projects to read directly from the Pi, but using existing Python via Serial, to get my values.

Without taking a large number of hours to formally learn python, I have a moderate understanding of its syntax and controls, but I am struggling to understand and adapt this line:

 

# data that we're sending to Power BI REST API
data = '[{{ "timestamp": "{0}", "temperature": "{1:0.1f}", "humidity": "{2:0.1f}" }}]'.format(now, temp, humidity)

 

I need to understand how to replace the formatting components with a string and a float variable similar to below.  Ideally I'd like to better understand the formatting function, while I don't necessarily need it here, I am sure it will be useful in the future.  I've already populated the variables, and in my current iteration, pump that data into a mySQL database.   I am trying to eliminate that component overall, by leveraging streaming dataset instead.  Maybe it would be easier for me to understand this line with similar formatting, before i try and adjust the one used with the REST API.

 

print 'Temp={0:0.1f}*C Humidity={1:0.1f}%'.format(temp, humidity)

 

 

 

Can someone give me a mid-level breakdown of what the formatting components of this line are?


Viewing all articles
Browse latest Browse all 48084

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>