Skip to content

editorialapp/datatools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@editorialapp/datatools

A collection of dependencies organized into useful tools for working with data in ways that are common in data cleaning and in building news apps.

These tools assume they will be used as part of scripts run with Node.js.

Turn a directory of markdown into a sqlite3 table

An example taken from the tests:

import { markdownDirectoryToTable } from '@editorialapp/datatools'
import * as dirname from 'desm'

const markdownDirectory = dirname.join(import.meta.url, './fixtures/markdown')

// an instance of Database from better-sqlite3 is returned
const db = await markdownDirectoryToTable({
	directoryFilepath: markdownDirectory,
	tableName: 'markdown',
	columns: {
		title: 'TEXT',
		content: 'TEXT'
	}
})

const rows = await db.prepare('SELECT * FROM markdown;').all()

console.log(rows)
// returns:
// [
// 	{ title: 'B', content: '<p>This is b.</p>\n' },
// 	{ title: 'C', content: '<p>This is c.</p>\n' },
// 	{ title: 'A', content: '<p>This is a.</p>\n' }
// ]

License

Apache-2.0

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published