When reading from Google Sheet with Python and the Google API I have a hard time getting numeric values from the numeric values.
Where i live we use comma as decimal separator, which seems to be the problem.
The Google sheet input is:
with automatic format.
The Python script is:
gc = gspread.service_account(filename="gdocs_access.json")
sh = gc.open("my_file").worksheet("sheet 1")
data = sh.get_all_records(numericise_ignore=["all"])
print(data)
[{'id': 'b', 'value': '200,3'}, {'id': 'c', 'value': '40'}, {'id': 'a', 'value': '-30,5'}]
returning all numeric values as string.
If I put this in a df and convert the string values to int:
data = pd.DataFrame(data)
data['value'].astype(int)
I get this error:
ValueError: invalid literal for int() with base 10: '200,3'
Apparently this error is caused when passing a string representation of a float into int, but that does not help me much. It does not help me to first convert to float.
Is there a solution for this? I am sure I am not the first one using comma as decimal and trying to read Google sheets with Python.