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

@jo-sm/parse-stages-csv

v1.2.0

Published

Parse Stages cycling CSV files

Downloads

13

Readme

parse-stages-csv

parse-stages-csv is a parser for Stages indoor bicycle CSV data. It allows for parsing the raw CSV data, turning it into a more usable object, with additional metadata like the current stage that the line was recorded during.

Installation

npm install @jo-sm/parse-stages-csv

The package is available via both NPM and the Github package repositories.

Usage

import { parseFile as parseStagesCSV } from "@jo-sm/parse-stages-csv";

const filename = "my-workout-data.csv";

for await (const datum of parseStagesCSV(filename)) {
  doSomethingWith(datum);
}

parseStagesCSV is an async generator function and so can be used like above in an async for...of loop. Each datum is a line, in order, from the CSV, parsed depending on the format (e.g. currentTime is an integer of the seconds since the start of the workout).

Note that data that the parser considers "unreliable", i.e. data with a bad COM value, as well as lines where the current time does not parse correctly, are ignored.

Options

You can optionally pass in two options, stages and normalize.

The stages option allows you to select which stages you want in your output. Passing in a number or an array of a single number treats it as if you want just that stage, while passing in an array of numbers selects those stages.

for await (const datum of parseStagesCSV(filename, { stages: [3, 5] })) {
  // Do something with data for stages 3, 4, and 5
}

The normalize option normalizes the resulting time and distance to the first parsed stage, e.g. instead of getting a time of 602 for the first datum when passing in a stage, you will get a time of 0.

Data shape

Each datum has the following shape:

{
  currentTime, // in seconds
  km, // total distance traveled so far
  kmPerHour, // current KPM
  watts, // current power
  heartRate, // current heart rate or 0
  rpm, // current RPM
  misc: {
    currentStage
  }
}

Issues with parsing

The parser expects the data to laid out like the fixture CSV, as this is the only data I have access to so far. If you have a different format, or have issues parsing this format (for example, it does not parse the stage correctly), please create an issue with the CSV file!

License

MIT