I am reading data from Excel columns and saving it in a numpy array with a self written function. I Have a problem with only one of them.
Here is the function:
import numpy as np
import xlrd
import os
# Data Path
input_data_path = os.path.join(os.path.dirname(__file__), "..", r"Input.xlsx")
def read_excel_file_column(filepath, sheetpage, column=0):
"""Gives back a Excel-column as array"""
# file
book = xlrd.open_workbook(filepath, encoding_override="utf-8")
# sheet
sheet = book.sheet_by_index(sheetpage)
# numpy-Array
data = np.array([sheet.cell(i, column).value for i in range(sheet.nrows)])
return data
Then I am calling the function and reading a column from my excel file which has a string in its first line and after that 49 float values and print it out
time_robot = read_excel_file_column(input_data_path, 2, column=5)
print(time_robot)
Here is the output:
['CTRobot' '3.9000000000000004' '0.8999999999999999' '4.199999999999999'
'6.75' '5.25' '4.35' '6.8999999999999995' '10.35' '3.3000000000000003'
'3.3000000000000003' '38.25' '6.1499999999999995' '7.199999999999999'
'4.050000000000001' '2.4000000000000004' '2.4000000000000004' '1.0'
...]
I don't understand why there are so many post decimal positions.
I checked my Excel sheet and removed all foormatting, to make sure it not just shows me the rounded values or something
Whats also very interesting is, that it works perfectly fine with column "E" which is basically the same: Column E
Function Call:
time_human = read_excel_file_column(input_data_path, 2, column=4)
Output:
['CTHuman' '2.6' '0.6' '2.8' '4.5' '3.5' '2.9' '4.6' '6.9' '2.2' '2.2'
'25.5' '4.1' '4.8' '2.7' '1.6' '1.6' '9.2' ...]
I am working on Windows 10 and with python 3.7.5.