Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pozil/csv-visualizer
A visualizer that parses CSV data and renders it in a table in Postman or in a browser.
https://github.com/pozil/csv-visualizer
csv postman visualizer
Last synced: about 2 months ago
JSON representation
A visualizer that parses CSV data and renders it in a table in Postman or in a browser.
- Host: GitHub
- URL: https://github.com/pozil/csv-visualizer
- Owner: pozil
- License: cc0-1.0
- Created: 2021-09-06T17:51:24.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-19T04:04:28.000Z (over 1 year ago)
- Last Synced: 2024-11-14T13:35:51.904Z (about 2 months ago)
- Topics: csv, postman, visualizer
- Language: JavaScript
- Homepage:
- Size: 908 KB
- Stars: 19
- Watchers: 1
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![npm](https://img.shields.io/npm/v/csv-visualizer)](https://www.npmjs.com/package/csv-visualizer)
# Postman CSV Visualizer
A visualizer that parses CSV data and renders it in a table in Postman or in a browser.
1. [Example](#example)
1. [Using the Visualizer in Postman](#using-the-visualizer-in-postman)
1. [Reference](#reference)## Example
The following code...
```html
const CSV = '"h1","h2","h3"\n"r1c1","r1c2","r1c3"\n"r2c1","r2c2","r2c3"';
CsvVisualizer.visualize(CSV);```
...generates a table like this:
![Standalone HTML table](./gfx/simple-table.png)
Complete example available in [example.html](example.html).
## Using the Visualizer in Postman
1. Pick a request that returns CSV data
1. Copy the following code in the **Tests** tab:```js
const template = `
pm.getData((err, data) => {
CsvVisualizer.visualize(data.csvString);
});
`;
const csvString = pm.response.text();
pm.visualizer.set(template, { csvString });
```1. Run the request and open the response's **Visualize** tab
![Postman visualizer](./gfx/postman.png)
## Reference
```js
CsvVisualizer.visualize(
csvString,
(rootElement = document.body),
(options = {})
);
````csvString` - the CSV string that holds the table data
`rootElement` - optional, the root DOM element to witch the content is appended. If not specified, `document.body` is used.
`options` - optional, an object that contains the table and parser options:
| Property | Type | Default | Description |
| --------------- | --------- | ------- | ----------------------------------------------------------------------------------- |
| `showHeader` | `boolean` | `true` | Whether the table should have a header that indicates the number of rows. |
| `parserOptions` | `Object` | `{}` | CSV parser options. See [Papa Parse Config](https://www.papaparse.com/docs#config). |## Credits/Licenses
This project uses [Papa Parse](https://www.papaparse.com/) (MIT License) for CSV parsing.