I have python script, “convert_json_to_csv.py”.
When I hit return I get error, “NameError: name ‘convert_json_to_csv’ is not defined”.
Below is the script contents:
import pandas as pd
json_file_path = 'trulab.json' # Path to your JSON file
csv_file_path = 'trulab.csv' # Path where CSV file will be saved
def json_to_csv(json_file_path, csv_file_path):
# Read JSON file into a dataframe
df = pd.read_json(json_file_path, lines=True)
# Save dataframe to a CSV file, delimited by a pipe
df.to_csv(csv_file_path, index=False, sep='|')
json_to_csv(json_file_path, csv_file_path)
Please advise.
Thank you for your time and help.
Best Regards,
Donald
I tried to run script from command line
I was expecting python to run script
but it seems it ‘thinks’ my script is an undefined variable.
I am brand new to python.