Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write npm script to ingest Jackson property list #66

Open
replygirl opened this issue Aug 11, 2020 · 12 comments
Open

Write npm script to ingest Jackson property list #66

replygirl opened this issue Aug 11, 2020 · 12 comments
Assignees
Labels
✨ feature New feature or request ⭐ ⭐ Intermediate Somewhat difficult 🤔 question Further information is requested 👋 help wanted Extra attention is needed

Comments

@replygirl
Copy link
Contributor

This script should take in an Excel sheet (the property list) and add the items to Contentful

The property list: https://public.3.basecamp.com/p/5Y3wNeeDbJmqGXtGr3UU9Ud1

Fields of interest:

  • Address: Use this to find the coordinates
  • Owner: Use this to exclude non-CJ properties (QUESTION: should we discuss data model update to specify owner?)
  • Dimension W + L: Use this to specify the bounds of a Lot (QUESTION: orientation?)
@replygirl replygirl added 👋 help wanted Extra attention is needed 🤔 question Further information is requested ✨ feature New feature or request ⭐ ⭐ Intermediate Somewhat difficult labels Aug 11, 2020
@replygirl replygirl changed the title Write npm script to ingest buildings from Jackson property list Write npm script to ingest Jackson property list Aug 11, 2020
@replygirl
Copy link
Contributor Author

From Basecamp:

This list is a year old- someone should check back with saki to make sure this is still how it is.

So we'll need to run this again with an updated xlsx before we release

@replygirl
Copy link
Contributor Author

replygirl commented Jan 26, 2021

update, to be continued
IMG_0114

Schemes needed:

  • contentful
  • js/json (not sure what for, it’s just low hanging fruit here)
  • TBD

Consider switching from Excel to Airtable? idk

@yeti-detective
Copy link
Collaborator

yeti-detective commented Jan 26, 2021

So my preliminary questions are basically: "How do I post something to Contentful?" which it looks like @replygirl will give me the rundown, and what schemes are needed, which will probably be evident from the answer to the above.
Also, the sample XLSX kind of looks like something that would be downloaded from a public records site. Do we have control over the file or does it come from an outside source?

@replygirl
Copy link
Contributor Author

replygirl commented Jan 27, 2021

Also, the sample XLSX kind of looks like something that would be downloaded from a public records site. Do we have control over the file or does it come from an outside source?

This is provided by Cooperation Jackson folks, we can reformat it and migrate it to anywhere we please--in other words, there isn't a hard spec for the input format other than what we see in the data

@yeti-detective yeti-detective self-assigned this Jan 30, 2021
@yeti-detective
Copy link
Collaborator

I'm going to start with a class that can consume an XLSX and extract the fields needed to build the types in types/db/contentful.d.ts
It can be a child of a larger class that supports more input sources and outputs these Contentful interfaces.

@yeti-detective
Copy link
Collaborator

I didn't get as far as I wanted to over this weekend (my Typescript is rustier than I thought) but I've pushed some work to a branch in my fork and I'll pick it back up if I have any free time this week (he won't) or next weekend, otherwise.

@yeti-detective
Copy link
Collaborator

yeti-detective commented Feb 8, 2021

Progress Update: I've gotten the script to the state where you should be able to run yarn import-xlsx <absolute or relative path to XLSX file> and the console will identify the sheet, column, and row containing the header "Address" (not case sensitive)
I've only tested the relative path bit on Rasbian, so I bet it works an any Debian Linux distro, but if anybody has easy access to a Mac/Windows machine they might want to give it a shot. I feel pretty confident absolute path would work on any platform.

Sorry about the slow progress. One of the speedbumps was getting ts-node to run in script mode with the main tsconfig.json file specifying "isolatedModules": true, but I found out you can override that setting by adding another tsconfig.json to a sub-directory, so I added scripts/ which can be a place where we want scripts to live, and excluded it from the build path in the main tsconfig.

edit: I made sure yarn build still runs after I did all that stuff I said up there ^^

@yeti-detective
Copy link
Collaborator

I got a little further this weekend. Next run, I'm going to see if I can get lat & long from the Google Maps API without registering api keys 🤞

@yeti-detective
Copy link
Collaborator

I have an update! So there doesn't appear to be an API that will convert an address string to latitude and longitude without registering with mapquest or Google or something. We can come back to that at a later time if we need to. What I currently have is a class that will scan through the worksheets of an XLSX file looking for something defined as 'content' (which I've currently defined as a header cell containing the text, "Address," non-case-sensitive, and then the data ).
So, to finish this out I'm going to make it configurable for the fields that the IBuildingFields interface wants (unless ILotFields would be better? It looks like it takes an IBuilding also).
I'll give it a default configuration, and also a method for changing the config in the event that is necessary.
I hope this comment makes sense.

@yeti-detective
Copy link
Collaborator

I've made progress yet again! I just need to finish it off with the post to Contentful.

@yeti-detective
Copy link
Collaborator

I am like 1/2 step away from successfully posting to Contentful, but I have to go to bed, so I will pick up later.

yeti-detective added a commit that referenced this issue Apr 11, 2021
adding class XlsxImporter

add scripts/ with tsconfig override, update file path in package.json

exclude scripts/ from build

add scripts/ with tsconfig override, update file path in package.json

run 'yarn import-xlsx <relative path to spreadsheet>' to identify sheet, column, and row of cell containing header 'Address' (not case sensitive)

TS compatible regex matcher function

add readme instructions for running script
@yeti-detective
Copy link
Collaborator

Test Sample Buildings.xlsx
attaching the sample spreadsheet used in the Loom demo on PR 89

replygirl pushed a commit that referenced this issue Apr 19, 2021
* first draft for initial PR, addresses issue #66

adding class XlsxImporter

add scripts/ with tsconfig override, update file path in package.json

exclude scripts/ from build

add scripts/ with tsconfig override, update file path in package.json

run 'yarn import-xlsx <relative path to spreadsheet>' to identify sheet, column, and row of cell containing header 'Address' (not case sensitive)

TS compatible regex matcher function

add readme instructions for running script

* typo in readme & remove unused class property

* another README typo

* tiny bug fix

* add Google Apps Script instructions for parsing lat/lon from text address in a Google Sheet

* newlines in MD

* README typos

Co-authored-by: brownc08 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ feature New feature or request ⭐ ⭐ Intermediate Somewhat difficult 🤔 question Further information is requested 👋 help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants