How to transform data to use as .json
From Tableau CSV to JSON — Filtering Columns via Excel and Python
This Standard Operating Procedure outlines how to transform a CSV report downloaded from Tableau, filter specific columns using an Excel reference file, save the filtered data as a new CSV, and finally convert it to JSON using Python.
📥 Step 1: Download the Report from Tableau
- Open the Tableau dashboard.
- Export the report as a CSV file.
- Save it locally as
tableau_report.csv.
📘 Step 2: Prepare the Excel File with Desired Headers
- Open Excel and create a new file named
questions_and_fields_mapping.xlsx. - In Column A, list the exact names of the columns you want to keep.
- Save the file.
🧹 Step 3: Filter Columns in Excel
- Open
tableau_report.csvin Excel. - Use VLOOKUP, FILTER, or Power Query to match the headers in the CSV with those listed in
desired_columns.xlsx. - Remove any columns not listed in the reference file.
- Save the filtered result as
filtered_report.csv.
🐍 Step 4: Convert the Filtered CSV to JSON Using Python
import pandas as pd
# Load the filtered CSV
df = pd.readcsv('filteredreport.csv')
# Save as JSON
df.tojson('finalreport.json', orient='records', lines=True)
✅ Final Output
filtered_report.csv: Contains only the relevant columns.final_report.json: JSON version ready for integration, analysis, or sharing.
Comentarios
Publicar un comentario