Am trying to create a dynamic form that allows users to upload a .csv file & then nominate the data type & format for each column, e.g. if the column contains Date data, user selects ‘Date’ from one dropdown and then the specific date format from another.
A dynamic form is preferred since the number of columns / items per row can vary as can the order, i.e. one .csv might be category/item/date, another might be date/category/item etc. etc. and can also contain a bunch of columns we just want to ignore.
Examples:
- British/American day & month formats are different by convention
- .csv output format varies per software package; some put the date column first, some will put it last
- Multiple date fields / multiple category fields - such as two or more date fields - I’d like to flexibility to select one date column to start with, and then choose another later.
- point cloud data XYZ RGB (coordinates & colour)
Here’s some simplified code of how far I’ve got (not very):
def import_form (self):
fp = FlowPanel()
# add dropdown to nominate data type
lp = LinearPanel()
dd1 = DropDown(items=['Item Name', 'Date', 'Category'], placeholder='Ignore', include_placeholder=True)
dd1.set_event_handler("change", self.dd1_state)
lp.add_component(dd1)
# second dropdown placeholder - add dd2.items later based on dd1 (how?)
dd2 = DropDown()
lp.add_component(dd2)
#### 5-10 rows of data ####
# add the linear panel to the flow panel
fp.add_component(lp)
# repeat for each column of data
# linear panels contain the columns, flow panel controls left-to-right layout
def dd1_state(self, sender,**event_args):
# user selections
selection = sender.selected_value
No clone to share (yet). Any idea how I can use the selected value of a specific dd1 to change what is shown on dd2? I’ve read quite a bit about the use of tags, but I’m not sure that is the way to go here.
I’m not adverse to a strict column sequence and data format if this is what’s ultimately needed (i.e. sort it all out in excel first), but I thought I’d try and and offer something a bit cleverer…