Export data from Python into Tableau using JSON?
Asked Answered
E

1

2

How do I get 4 million rows and 28 columns from Python to Tableau in a table form?

I assume (based on searching) that I should use a JSON format. This format can handle a lot of data and is fast enough.

I have made a subset of 12 rows of the data and tried to get it working. The good news is: it's working. The bad news: not the way I want to.

My issue is that when I import it in Tableau it doesn't look like a table. I have tried the variances which are displayed here.

This is the statement in Python (pandas):

jsonfile = pbg.to_json("//vsv1f40/Pricing_Management$/Z-DataScience/01_Requests/Marketing/Campaign_Dashboard/Bronbestanden/pbg.json",orient='values')

Maybe I select too many schemas in Tableau (I select them all), but I think my problem is in Python. Do I need to use another library instead of Pandas? Or do I need to change the variables?

Other ways are also welcome. I have no preference for JSON, but I thought that was the best way, based on the search results.

Note: I am new to python and tableau :) I use python 3.5.2 and work in Jupyter. From Tableau I only have the free trial desktop version.

Effortful answered 6/1, 2017 at 15:32 Comment(0)
U
3

JSON is good for certain types of data, but if your DataFrame is purely tabular (no MultiIndexes, complex objects, etc.) and contains simple data types (strings, digits, floats), then a comma-separated value (CSV) text file is probably the best format to use, as it would take up the least space. A DataFrame can easily be saved as a CSV using the to_csv() method, and there are a number of customization options available. I'm not terribly familiar with Tableau, but according to their website CSV files are a supported input format.

Uturn answered 6/1, 2017 at 16:2 Comment(4)
MattDMo is correct. Once you have a csv file, Tableau will connect and read it without any further requirements.Eolic
Ok thanks! I thought Json would be the best way. I tried csv with a smaller dataset and that worked. So no problem to get csv working. Thanks for your answers!Effortful
wouldn't xlsx be way more efficient?Harbaugh
@Harbaugh why would it be more efficient? The csv module built in to Python is quite fast and efficient, and CSV files take up less space than the equivalent pure tabular data stored in a native Excel spreadsheet, which contains all kinds of XML overhead.Uturn

© 2022 - 2024 — McMap. All rights reserved.