# xy-parser

> Parse a text-file and convert it to an array of XY points

Latest version **6.0.1** (published 2026-02-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install xy-parser
pnpm add xy-parser
yarn add xy-parser
bun add xy-parser
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 6.0.1 |
| Published | 2026-02-26 |
| First published | 2015-05-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 3 |
| Unpacked size | 22.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Luc Patiny |
| Maintainers | targos, lpatiny, cheminfo-bot, stropitek |
| Keywords | xy file parser, mass spectroscopy |

## Links

- npm: https://www.npmjs.com/package/xy-parser
- Repository: https://github.com/cheminfo/xy-parser
- Homepage: https://github.com/cheminfo/xy-parser#readme
- Issues: https://github.com/cheminfo/xy-parser/issues
- npm.io page: https://npm.io/package/xy-parser

## Dependencies (3)

- [ensure-string](https://npm.io/package/ensure-string.md) ^2.0.0
- [cheminfo-types](https://npm.io/package/cheminfo-types.md) ^1.10.0
- [ml-spectra-processing](https://npm.io/package/ml-spectra-processing.md) ^14.21.0

## Recent versions

- 6.0.1 (latest) — 2026-02-26
- 6.0.0 — 2026-02-25
- 5.0.5 — 2024-03-07
- 5.0.4 — 2023-03-24
- 5.0.3 — 2022-11-25
- 5.0.2 — 2022-03-15
- 5.0.1 — 2022-02-25
- 5.0.0 — 2022-02-16
- 4.0.1 — 2021-12-15
- 4.0.0 — 2021-11-09
- 3.2.0 — 2021-07-14
- 3.1.1 — 2021-03-19
- 3.1.0 — 2021-03-19
- 3.0.0 — 2019-10-11
- 2.2.2 — 2018-06-27
- … 6 more at https://npm.io/package/xy-parser/versions

## README

# xy-parser

Parse a text-file and convert it to an array of XY points.

<h3 align="center">

  <a href="https://www.zakodium.com">
    <img src="https://www.zakodium.com/brand/zakodium-logo-white.svg" width="50" alt="Zakodium logo" />
  </a>

  <p>
    Maintained by <a href="https://www.zakodium.com">Zakodium</a>
  </p>

[![NPM version][npm-image]][npm-url]
[![Test coverage][codecov-image]][codecov-url]
[![npm download][download-image]][download-url]
[![DOI](https://www.zenodo.org/badge/35540080.svg)](https://www.zenodo.org/badge/latestdoi/35540080)

</h3>

## Installation

`$ npm install --save xy-parser`

## Usage

```js
import { parseXY } from 'xy-parser';
const data = `My file
1   2
3   4
5   6
7   8`;
const result = parseXY(data);
/* result ->
    {
      x: [1, 3, 5, 7],
      y: [2, 4, 6, 8]
    }
  }
*/

const result2 = parseXYAndKeppInfo(data);
/* result2 ->
    data: {
      x: [1, 3, 5, 7],
      y: [2, 4, 6, 8]
    },
    info: [
      'My file'
    ]
  }
*/
```

The `bestGuess` option will try to determine which columns should be used.

If there are 3 columns and the first column is a sequential number starting at '1' it looks
like this is a line number, we will ignore it.

If there are many columns maybe we have a format like X1, Y1, X2, Y2, ... in this cases if one
column on two is a monotone series we will parse it correctly.

## [API Documentation](https://cheminfo.github.io/xy-parser/)

## License

[MIT](./LICENSE)

[npm-image]: https://img.shields.io/npm/v/xy-parser.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/xy-parser
[codecov-image]: https://img.shields.io/codecov/c/github/cheminfo/xy-parser.svg?style=flat-square
[codecov-url]: https://codecov.io/gh/cheminfo/xy-parser
[download-image]: https://img.shields.io/npm/dm/xy-parser.svg?style=flat-square
[download-url]: https://www.npmjs.com/package/xy-parser

---
_Source: https://npm.io/package/xy-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
