30
loading...
This website collects cookies to deliver better user experience
xlsb
for binary Excel data.pandas
, motivated by a short real-world example.t
, representing the time in seconds, and a (mg)
the corresponding acceleration value in micro-g.BytesIO
, a standard Python package that can parse a stream of bytes using a specific encoding, and pandas
, which, quoting the official website, " is a fast, powerful, flexible and easy to use open source data analysis and manipulation tool, built on top of the Python programming language.". Note that the read_excel
built-in function from pandas requires installing an additional dependency: openpyxl
.read_excel
function. dataFiles
and we want to parse the first file in the list. Assuming mongoClient
is a configured and ready-to-use client, the chaining code would look like:import pandas as pd
(...)
excel_data = pd.read_excel(io.BytesIO(mongoClient['dataFiles'][0]))
excel_data
we have an array of Nx2 entries, where N is total number of rows in the excel file, which, in this example is 4000, so, when we print the variable to the console, here is the output:t a (mg)
0 0.00 0.000358
1 0.02 -0.000466
2 0.04 -0.000181
3 0.06 0.000697
4 0.08 0.000618
... ...
3996 79.92 -0.001205
3997 79.94 0.000120
3998 79.96 -0.000061
3999 79.98 -0.000022
4000 80.00 0.000142
excel_data['t'][0]
will give us back the value 0.00 as a 64 bit float value, typed, as we wanted.