Home/Support/Support Forum/TabPy: Python returning Json into Tableau, “Error Parsing Number”
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

TabPy: Python returning Json into Tableau, “Error Parsing Number”

0 votes
I am trying to use Tableau calculated field to use my python script, which gets JSON data. My ultimate goal is to get this data into tableau in a tabular format.

I have read JSON is easier to get into tableau as opposed to dataframe object.

I currently use it in Spyder program. and execute this to get my data.

Code [ print (get1D ("2019-02-02", "2019-02-05", "Tableau", "Limits")) ]

In my calculated field I get the error: "Error Parsing Number" on

Code [ .format(status_code)) ]

error msg:

Any help would be appreciated on getting this data into tableau. Here is my full script.


import time

import requests

import json

import pandas as pd

import re

import urllib3

import math

from io import StringIO

from datetime import datetime, date,timedelta

from pandas.tseries.offsets import BDay

from urllib.parse import urlencode

from flask import json

def call_api(url, request_dict, post):

if post:

header = {'content-type':'application/json'}

resp = requests.post(url, data=json.dumps(request_dict), auth=('user', 'pass'), headers = header, verify=False)


url = url + urlencode(request_dict)

resp = requests.get(url, auth=('user', 'pass'), verify=False)

status_code = resp.status_code

if status_code == 401:

raise ValueError("There is an error with the connection.\nLogin failed. \nNot authorized. Please check your credentials and try again.\nStatus code {}".format(status_code))

elif status_code == 404:

raise ValueError("There is an error with the connection.\nCould not connect to the server.\nStatus code {}".format(status_code))

elif status_code == 200:



raise ValueError("There is an error with the connection.\nStatus code {}".format(status_code))

return resp

def getData (startDate, endDate, nodeName, Type, Id):

request_dict = [{

"hierarchy": "Tableau",

"nodeName": nodeName,

"FilterId": Type,

"Id": Id ,


url = "https://sampleurl/startDate={0}&endDate={1}"

startDate = datetime.strptime(startDate, '%Y-%m-%d')

startDate = startDate.strftime ('%Y%m%d')

endDate = datetime.strptime(endDate, '%Y-%m-%d')

endDate = endDate.strftime ('%Y%m%d')

url = url.format(startDate, endDate)

resp = call_api(url, request_dict, True)

return resp.json ()

def get1D(startDate, endDate, nodeName, Type):

return getData (startDate, endDate, nodeName, Type, 1)

) ]
asked Jul 31 in 3rd Party Python and API development in other Languages by tobimarsh43 New to the Community (0 points)

Please log in or register to answer this question.