# AUTOGENERATED! DO NOT EDIT! File to edit: notebooks/02_TidyAddr.ipynb (unless otherwise specified).

__all__ = ['runTidyAddr']

# Cell
# Input: A CSV with a single column titled 'address' (may require pre-processing to get it like this)
# Output: A CSV with a single column containing text that can be split into 5 columns in xl.
# - Needs to be re-merged with any other columns removed before tidy addring.
import os
def runTidyAddr( filename, newfilename ):
  print( filename, newfilename )
  print(' ~~~~~~~~~~~ Getting TIDYADDR ~~~~~~~~~~~ ')
  ! rm tidyaddr-js -r
  ! git clone https://github.com/BNIA/tidyaddr-js.git
  print(' ~~~~~~~~~~~ Installing TIDYADDR ~~~~~~~~~~~')
  ! echo ORIGINAL_DIRECTORY && echo $(ls)
  ! cp *.csv tidyaddr-js/ && cd tidyaddr-js && npm install
  print(' ~~~~~~~~~~~ Running TIDYADDR ~~~~~~~~~~~')
  ! echo TIDYADDR_DIRECTORY && cd tidyaddr-js && echo $(ls)
  txt = "cd tidyaddr-js && node tidyaddr.js clean-csv " + filename + " " + newfilename
  os.system(txt)

runTidyAddr( uploadedFilename, './'+uploadedFilename.replace(".", "_tidyaddred.") )