Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
municipalities-by-province
Advanced tools
Readme
ph-municipalities have npm scripts that allow interactive querying of Philippines municipalities included in one or more provinces or from a whole region, with an option of writing them to JSON files from the command line.
It uses /data/day1.xlsx
(downloaded and stored as of this 20220808) from PAGASA's 10-day weather forecast excel files as the default data source.
It also asks users to key in the download URL of a remote excel file should they want to use another excel file for a new and updated data source.
Extracted municipalities are written in JSON files following the format:
{
"metadata": {
"source": "https://pubfiles.pagasa.dost.gov.ph/pagasaweb/files/climate/tendayweatheroutlook/day1.xlsx",
"title": "List of PH Municipalities By Province and Region",
"description": "This dataset generated with reference to the excel file contents from the source URL on 20220808.",
"date_created": "Mon Aug 08 2022"
},
"data": {
"Albay": ["Bacacay", "Camalig", ... ],
"Camarines Norte": ["Basud", "Capalonga", ... ],
"Camarines Sur": ["Baao", "Balatan", ... ],
...
}
}
The following dependencies are used for this project. Feel free to use other dependency versions as needed.
/data
directory as data source."municipalityName (provinceName)"
/data/day1.xlsx
sample file for more informationEXCEL_FILE_URL
variable on the Installation section.Clone this repository.
git clone https://github.com/ciatph/municipalities-by-province.git
Install dependencies.
npm install
Create a .env
file from the .env.example
file. Use the default values for the following environment variables.
Variable Name | Description |
---|---|
EXCEL_FILE_URL | (Optional) Remote excel file's download URL. If provided, the excel file will be downloaded and saved on the specified pathToFile local filesystem location during the ExcelFile class initialization.Read on Usage for more information. |
SHEETJS_COLUMN | Column name read by sheetjs in an excel file. This column contains the municipality and province names following the string pattern "municipalityName (provinceName)" Default value is __EMPTY |
SORT_ALPHABETICAL | Arranges the municipality names in alphabetical order. Default value is 1 . Set to 0 to use the ordering as read from the Excel file. |
npm start
/ npm run list:region
/data/day1.xlsx
by default./data/datasource.xlsx
if download URL input is provided.npm run list:province
/data/day1.xlsx
by default./data/datasource.xlsx
if download URL input is provided.npm run example
await
build:win:region
npm start
script into a stand-alone windows node16-win-x64
executable./build/ph-regions-win.exe
. Click the executable file to run.build:win:province
npm list:province
script into a stand-alone windows node16-win-x64
executable./build/ph-provinces-win.exe
. Click the executable file to run.build:win:all
npm start
and npm list:province
script into a stand-alone windows node16-win-x64
executables in one go./build
directory.npm run minify:region
npm list:region
script and dependencies into a single script using ncc./build/region
. Run the command to use the compiled script:node build/region
npm run minify:province
npm list:province
script and dependencies into a single script using ncc./build/province
. Run the command to use the compiled script:node build/province
npm run minify:all
npm list:region
and npm list:province
scripts in one go./build
directory.npm run lint
Lint JavaScript source codes.
npm run lint:fix
Fix JavaScript lint errors.
const path = require('path')
const { ExcelFile } = require('./classes/excel')
// Reads an existing excel file on /data/day1.xlsx
file = new ExcelFile({
pathToFile: path.join(__dirname, '..', 'data', 'day1.xlsx')
})
try {
file.init()
} catch (err) {
console.log(`[ERROR]: ${err.message}`)
}
// JSON data of the parsed excel file will be accessible on
// file.datalist
require('dotenv').config()
const path = require('path')
const { ExcelFile } = require('./classes/excel')
const main = async () => {
// Excel file will be downloaded to /data/day1.xlsx
file = new ExcelFile({
pathToFile: path.join(__dirname, '..', 'data', 'day1.xlsx'),
url: process.env.EXCEL_FILE_URL
})
try {
await file.init()
} catch (err) {
console.log(err.message)
}
// JSON data of the parsed excel file will be accessible on
// file.datalist
}
main()
Initialize an ExcelFile
class instance.
require('dotenv').config()
const path = require('path')
const { ExcelFile } = require('./classes/excel')
const PHExcel = new ExcelFile({
pathToFile: path.join(path.join(__dirname, '..', '..', 'data', 'day1.xlsx')),
url: process.env.EXCEL_FILE_URL
})
PHExcel.init()
module.exports = PHExcel
Listen to the instance's EVENTS.LOADED
event.
PHExcel.events.on(PHExcel.EVENTS.LOADED, async () => {
console.log('Excel data loaded!')
})
The main npm scripts can be packaged into standalone windows executables.
npm run build:win:region
npm run build:win:province
# npm run build:win:all
/build
directory to execute.The main npm scripts can be compiled into standalone JavaScript files together with all its dependencies.
npm run minify:region
npm run minify:province
# npm run minify:all
/build
directory to execute.
node build/region
node build/province
@ciatph
20220807
FAQs
Extract the `municipalities` of a given `province` from an excel file and write them in a JSON file.
The npm package municipalities-by-province receives a total of 0 weekly downloads. As such, municipalities-by-province popularity was classified as not popular.
We found that municipalities-by-province demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.