Skip to content

Instantly share code, notes, and snippets.

@karlkaebnick
Last active July 18, 2019 20:08
Show Gist options
  • Save karlkaebnick/0c10d17c751178bffc36350dd3e6992b to your computer and use it in GitHub Desktop.
Save karlkaebnick/0c10d17c751178bffc36350dd3e6992b to your computer and use it in GitHub Desktop.
How to add, update or remove data from automated web pages
  1. If you have a report to add or replace, then let's take care of that first:
    • navigate to the web page where the report is supposed to be added or replaced (e.g., https://detroitmi.gov/departments/office-chief-financial-officer/financial-reports)
    • copy a link to an existing report to figure out where the new report or replacement report is supposed to go - e.g., if the link to a report that is already available on the page is https://detroitmi.gov/sites/detroitmi.localhost/files/migrated_docs/financial-reports/CityofDetroitOCFOMonthlyFinancialReportMay19FinalCC.pdf, then that indicates your new or replacement report should be uploaded to /var/www/html/detroitmi/docroot/sites/detroitmi.localhost/files/migrated_docs/financial-reports
    • sftp to the web server, e.g., sftp detroitmi.prod@web-35153.prod.hosting.acquia.com
    • navigate to the destination foldeer, e.g., cd /var/www/html/detroitmi/docroot/sites/detroitmi.localhost/files/migrated_docs/financial-reports
    • upload the file, e.g., put new_report.pdf
    • close your connection with the server, e.g., quit
  2. Login to smartsheets, find the folder 'Automated Web Pages', and open the smartsheet 'Automated Web Page Info' (or go here https://app.smartsheet.com/b/home?lx=zYOlh0ZOlGOUNKlZ5QRpOg).
    • This smartsheet contains information about each of the automated web pages, including a link to the web page itself, a link to the smartsheet where you can edit the data for the page, and links to the socrata dataset and a json api call to make to get the data from socrata.
  3. Once you have opened the smartsheet 'Automated Web Page Info', find the row corresponding to the web page you are updating.
  4. Once you have found the correct row, click on the Open Data URL in that row (this should be a link on data.detroitmi.gov - you may need to login to data.detroitmi.gov first in order for this to work)
  5. Choose Export / CSV to download a copy of the dataset, then open that dataset in an editor (you can use excel but I usually do this in a text editor)
  6. Add / edit / delete the rows that you are interested in changing.
    • If you are adding a row, generally that means first finding the correct section / subsection (the first column of the data will be a section, if the dataset has a subsection, then the second row will be a section), copying an existing row, inserting it in the correct place (usually as the first row of the section / subsection), then editing that row with the correct information (e.g., title, pub date, etc.). If the dataset has a column named Display Order (generally the last column) that column will need to be updated - every value in that column is unique and dictates the order in which the dataset is rendered in the website.
  7. Now that you have completed your changes to the csv file, return to the Open Data Portal page for this dataset and click the blue 'Edit' button, then the 'ADD DATA' button under 'Add Data' and choose 'Replace'. Now choose 'Browse' and open the csv you just updated. This will run an import on the data in the csv as a new 'draft' of the dataset. Once the import has run, you should see a message at the bottom of the screen that says "Rows that will not be imported 0" - if it says a number other than zero, than you have errors in the csv file that need to be fixed - in this case you should delete the draft, fix the errors (if you edited the csv file in excel than it is possible excel introduced errors), then run the import again.
  8. Once you have imported the csv file with no errors (and the correct number of rows to be imported), you can choose 'Save', then click the blue 'Update' button, and finally click 'Continue' to publish the new draft of the dataset - at this point your changes to the dataset are live.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment