Hi everyone. I have been using Anaconda for several years to do data analysis and I want to use jupyter in a way that will more easily show the process the code takes and to incorporate widgets to help slice and dice the data using pandas.
So far, I am failing miserably to accomplishing what I want. I think I am missing something and unfortunately I cannot seem to make examples work from the internet OR I find the same rehashed simplistic examples in every blog or medium post.
My basic code is below. I want to prompt the user to specify a directory that contains the CSVs to be imported then to specify where the output should be stored. I dont want to the code to run past the point of the prompt(s). It is key that the user is prompted before continuing with either prompt or them prompts as a set.
# import libraries
%matplotlib inline
import os
import sys
import glob
import datetime
import numpy as np
import pandas as pd
import matplotlib.dates as dates
import matplotlib.pyplot as plt
import ipywidgets as widgets
# prompt for data path
datadir_prompt = widgets.Text(placeholder='File path to data',description='Data Path:')
display(datadir_prompt)
outputdir_prompt = widgets.Text(placeholder='File path to data',description='Output Path:')
display(outputdir_prompt)
datadir = datadir_prompt.value
outputdir = outputdir_prompt.value
# document files found in datadir
print ('Data Directory:')
found_files = glob.glob(datadir+r'\*.csv')
[print(' {} found'.format(found_files)) for counter,files in enumerate(found_files)]
# report on outputdir
print ('Output Directory: \n {}'.format(outputdir),end=' ')
if os.path.exists(outputdir)==False:
os.mkdir(outputdir)
print('(created)')