npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

saw-the-table

v0.0.5

Published

Extract tables from spreadsheets

Downloads

291

Readme

saw-the-table 🪚 👁️

First it saw the table, then it sawed the tables! A tool that first "sees" tables in your spreadsheets, then "cuts" them out into separate CSVs.

What it does

Given any spreadsheet:

  1. 👁️ SEES tables using density and layout analysis
  2. 🪚 SAWS them into clean, separate CSV files

No more manual copying and pasting of table regions!

Algorithm

Uses a density-based scan to detect regions of data, considering cells as connected if they're close enough and the region is dense enough. Tables are detected by analyzing gaps and density patterns in the data, similar to how humans visually identify tables.

Features

  • Automatic Table Detection: Finds tables in spreadsheets using density and layout analysis
  • Multiple File Types: Supports .xlsx, .xls, .csv, and .tsv files
  • Batch Processing: Process single files or entire directories
  • Multi-sheet Support: Handles multiple sheets in Excel files
  • Clean Output: Each detected table is saved as a separate CSV file
  • Developer Friendly: Can be used as a CLI tool or as a library in your code

Installation

# Using npm
npm install saw-the-table

# Using yarn
yarn add saw-the-table

# Using bun
bun add saw-the-table

Usage

As a CLI Tool

# Process a single file
saw-the-table -i ./path/to/spreadsheet.xlsx -o ./output/dir

# Process a directory (recursively finds all compatible files)
saw-the-table -i ./path/to/spreadsheets -o ./output/dir

# With verbose output
saw-the-table -i ./input -o ./output -v

As a Library

import { extractTablesFromXLSX, extractTablesFromCSV } from 'saw-the-table';

// For Excel files
const buffer = await fs.readFile('spreadsheet.xlsx');
const tables = await extractTablesFromXLSX(buffer);

// For CSV/TSV files
const content = await fs.readFile('data.csv', 'utf-8');
const tables = await extractTablesFromCSV(content);

Output Format

For each input file, you get:

  • One CSV file per detected table
  • Files are named using the pattern: {original_name}-{sheet_name}-table{n}.csv

Example:

input/
  report.xlsx  (containing 2 tables in Sheet1)
  data.csv     (containing 1 table)

output/
  report-Sheet1-table1.csv
  report-Sheet1-table2.csv
  data-table1.csv

Development

# Install dependencies
bun install

# Run in development mode (with watch)
bun run dev

# Run the CLI directly from source (for testing)
bun run dev:run -- -i ./input -o ./output -v

# Build
bun run build

Future Roadmap

  • Implement streaming support for files
  • Make algorithm parameters configurable when used as SDK (density thresholds, gap rules, etc.)