Skip to content

Commit

Permalink
Pushed a fix to address Issue garethcull#2. I've now created some log…
Browse files Browse the repository at this point in the history
…ic to scan the uploaded csv and determine if there are any null values within. If there is a null value, an error message shows up on Step 2, which tells the user that there may be an error with a particular row.
  • Loading branch information
garethcull committed Apr 10, 2019
1 parent 55d0bbb commit 6d6c7c0
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 3 deletions.
36 changes: 36 additions & 0 deletions helper_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,42 @@ def preprocessing(data):
"""

# Check to see if the data has any null values

print('Is there any null values in this data? ' + str(data.isnull().values.any()))

# If there is a null value in the dataset, locate it and emit the location of the null value back to the client, else continue:

print(data.tail())

do_nulls_exist = data.isnull().values.any()

if do_nulls_exist == True:
print('found a null value')
null_rows = pd.isnull(data).any(1).nonzero()[0]
print('######### ORIGINAL ROWS THAT NEED UPDATING ##############')
print(null_rows)
# Need to add 2 to each value in null_rows because there

print('######### ROWS + 2 = ACTUAL ROW NUMBERS IN CSV ##############')
update_these_rows = []
for x in null_rows:
update_these_rows.append(int(x)+2)

print(update_these_rows)

emit('error', {'data': update_these_rows})






else:
print('no nulls found')




if isinstance(col1_val, int) or isinstance(col1_val, float):
print(str(col1_val) + ' this is a metric')
Expand Down
20 changes: 17 additions & 3 deletions static/js/forecastr_v4.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,13 @@ $(document).ready(function(){

// ******** THE CODE BELOW IS PLACEHOLDER CODE FOR MODEL VALIDATION AND WILL BE UPDATED IN A FUTURE RELEASE ******** //


$('#reload-button').on('click', function() {

// Refresh the app
location.reload(true);


});

// Display updates to user when the data is processing

Expand All @@ -636,10 +642,18 @@ $(document).ready(function(){
});


socket.on('error', function() {
socket.on('error', function(msg) {

// Store msg.data into a variable called arr
var error_data = msg.data;





// Update UI with error notice

$('#user-messaging').css({display:"block"});
$('#error-message').html('<b>Error: </b> Whoops! You may want to check the following rows in your csv for null values: <br/>' + 'Row #: ' + error_data)

});

Expand Down
33 changes: 33 additions & 0 deletions static/styles/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,39 @@

/* ******************* STEP TWO STYLING ****************************** */

#user-messaging {

width: 100%;
background-color: #fff7a5;
height: 43px;
padding-left: 16px;
padding-top: 4px;
top: 4px;
position: relative;
display:none;


}

#reload-button {

background-color: transparent;
color: #000;
padding: 5px;
padding-left: 10px;
padding-right: 10px;
font-size:9px;
border-radius: 5px;
border:1px solid #000;
position:relative;
float:right;
margin-left:10px;
right:294px;
top:-39px;


}


#menu1 {

Expand Down
7 changes: 7 additions & 0 deletions templates/build-forecast-v3.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ <h5>EXPECTED OUTPUT</h5>

<div id="step2" class="tab-pane fade">

<div id='user-messaging'>

<p id='error-message'></p>
<a id='reload-button' href="#">TRY AGAIN</a>

</div>

<h3 class='step-title'>REVIEW DATA: PRE-FORECAST</h3>
<br>

Expand Down

0 comments on commit 6d6c7c0

Please sign in to comment.