Skip to content

Commit

Permalink
Removed magic string
Browse files Browse the repository at this point in the history
  • Loading branch information
gabryelreyes committed Jun 26, 2024
1 parent 22c2023 commit 315ff92
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/pySupersetCli/cmd_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
LOG: logging.Logger = logging.getLogger(__name__)
_CMD_NAME = "upload"
_TEMP_FILE_NAME = "./temp.csv"
DATE_COLUMN = "date"

################################################################################
# Classes
Expand Down Expand Up @@ -127,7 +128,7 @@ def _execute(args, superset_client: Superset) -> Ret:
# Input is a dictionary, with keys as index
data_frame = pd.read_json(json_file, orient='index')

if "date" not in data_frame:
if DATE_COLUMN not in data_frame:
raise ValueError(
"No 'date' column found in the JSON file.")

Expand All @@ -137,7 +138,7 @@ def _execute(args, superset_client: Superset) -> Ret:
with open(_TEMP_FILE_NAME, 'rb') as csv_file:
upload_file = {'file': csv_file}
upload_body = {'already_exists': 'append',
'column_dates': ["date"],
'column_dates': [DATE_COLUMN],
'table_name': args.table}

# Upload the CSV file to the specified table
Expand Down

0 comments on commit 315ff92

Please sign in to comment.