You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/11/01 19:14:33 UTC

[GitHub] [superset] Antonio-RiveroMartnez commented on a diff in pull request #21922: feat: CSV File Upload form updates

Antonio-RiveroMartnez commented on code in PR #21922:
URL: https://github.com/apache/superset/pull/21922#discussion_r1010807662


##########
superset/views/database/forms.py:
##########
@@ -133,129 +124,136 @@ class CsvToDatabaseForm(UploadToDatabaseForm):
             ),
         ],
     )
-    con = QuerySelectField(
+    table_name = StringField(
+        _("Table Name"),
+        description=_("Name of table to be created with CSV file"),
+        validators=[
+            DataRequired(),
+            Regexp(r"^[^\.]+$", message=_("Table name cannot contain a schema")),
+        ],
+        widget=BS3TextFieldWidget(),
+    )
+    database = QuerySelectField(
         _("Database"),
+        description=_("Select a database to upload the file to"),
         query_factory=UploadToDatabaseForm.file_allowed_dbs,
         get_pk=lambda a: a.id,
         get_label=lambda a: a.database_name,
     )
     schema = StringField(
         _("Schema"),
-        description=_("Specify a schema (if database flavor supports this)."),
+        description=_("Select a schema if the database supports this"),
         validators=[Optional()],
         widget=BS3TextFieldWidget(),
     )
-    sep = StringField(
+    delimiter = StringField(
         _("Delimiter"),
-        description=_("Delimiter used by CSV file (for whitespace use \\s+)."),
+        description=_("Enter a delimiter for this data"),
         validators=[DataRequired()],
         widget=BS3TextFieldWidget(),
     )
     if_exists = SelectField(
-        _("Table Exists"),
-        description=_(
-            "If table exists do one of the following: "
-            "Fail (do nothing), Replace (drop and recreate table) "
-            "or Append (insert data)."
-        ),
+        _("If Table Already Exists"),
+        description=_("What should happen if the table already exists"),
         choices=[
             ("fail", _("Fail")),
             ("replace", _("Replace")),
             ("append", _("Append")),
         ],
         validators=[DataRequired()],
     )
-    header = IntegerField(
-        _("Header Row"),
-        description=_(
-            "Row containing the headers to use as "
-            "column names (0 is first line of data). "
-            "Leave empty if there is no header row."
-        ),
-        validators=[Optional(), NumberRange(min=0)],
-        widget=BS3TextFieldWidget(),
-    )
-    index_col = IntegerField(
-        _("Index Column"),
-        description=_(
-            "Column to use as the row labels of the "
-            "dataframe. Leave empty if no index column."
-        ),
-        validators=[Optional(), NumberRange(min=0)],
-        widget=BS3TextFieldWidget(),
-    )
-    mangle_dupe_cols = BooleanField(
-        _("Mangle Duplicate Columns"),
-        description=_('Specify duplicate columns as "X.0, X.1".'),
-    )
-    usecols = JsonListField(
-        _("Use Columns"),
-        default=None,
-        description=_(
-            "Json list of the column names that should be read. "
-            "If not None, only these columns will be read from the file."
-        ),
-        validators=[Optional()],
-    )
-    skipinitialspace = BooleanField(
-        _("Skip Initial Space"), description=_("Skip spaces after delimiter.")
-    )
-    skiprows = IntegerField(
-        _("Skip Rows"),
-        description=_("Number of rows to skip at start of file."),
-        validators=[Optional(), NumberRange(min=0)],
-        widget=BS3TextFieldWidget(),
-    )
-    nrows = IntegerField(
-        _("Rows to Read"),
-        description=_("Number of rows of file to read."),
-        validators=[Optional(), NumberRange(min=0)],
-        widget=BS3TextFieldWidget(),
+    skip_initial_space = BooleanField(
+        _("Skip Initial Space"), description=_("Skip spaces after delimiter")
     )
     skip_blank_lines = BooleanField(
         _("Skip Blank Lines"),
-        description=_("Skip blank lines rather than interpreting them as NaN values."),
+        description=_(
+            "Skip blank lines rather than interpreting them as Not A Number values"
+        ),
     )
     parse_dates = CommaSeparatedListField(
-        _("Parse Dates"),
+        _("Columns To Be Parsed as Dates"),
         description=_(
-            "A comma separated list of columns that should be parsed as dates."
+            "A comma separated list of columns that should be parsed as dates"
         ),
         filters=[filter_not_empty_values],
     )
     infer_datetime_format = BooleanField(
-        _("Infer Datetime Format"),
-        description=_("Use Pandas to interpret the datetime format automatically."),
+        _("Interpret Datetime Format Automatically"),
+        description=_("Interpret the datetime format automatically"),
     )
     decimal = StringField(
         _("Decimal Character"),
         default=".",
-        description=_("Character to interpret as decimal point."),
+        description=_("Character to interpret as decimal point"),
         validators=[Optional(), Length(min=1, max=1)],
         widget=BS3TextFieldWidget(),
     )
-    index = BooleanField(
-        _("Dataframe Index"), description=_("Write dataframe index as a column.")
+    null_values = JsonListField(
+        _("Null Values"),
+        default=config["CSV_DEFAULT_NA_NAMES"],
+        description=_(
+            "Json list of the values that should be treated as null. "
+            'Examples: [""], ["None", "N/A"], ["nan", "null"]. '
+            "Warning: Hive database supports only single value"

Review Comment:
   Oh Thanks! Fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org