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

  1. Open the Tableau dashboard.
  2. Export the report as a CSV file.
  3. Save it locally as tableau_report.csv.

📘 Step 2: Prepare the Excel File with Desired Headers

  1. Open Excel and create a new file named questions_and_fields_mapping.xlsx.

    In the example you can see I 
  2. In Column A, list the exact names of the columns you want to keep.
  3. Save the file.

🧹 Step 3: Filter Columns in Excel

  1. Open tableau_report.csv in Excel.
  2. Use VLOOKUPFILTER, or Power Query to match the headers in the CSV with those listed in desired_columns.xlsx.
  3. Remove any columns not listed in the reference file.
  4. 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