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

ngx-file-parser

v1.0.7

Published

Simple Angular component to parse CSV, JSON files

Downloads

90

Readme

ngx-file-parser

npm version

Simple component to parse files with extensions

  • CSV
  • JSON

To be implemented: XML....

See demo

Dependencies

Installation

1.

NPM: npm install ngx-file-parser --save

Yarn: yarn add ngx-file-parser

2.

Import the NgxFileParserModule to provide the necessary components and directives.

import { NgxFileParserModule } from 'ngx-file-parser';

@NgModule({
  ...
  imports: [ NgxFileParserModule ],
  ...
})
export class AppModule { }

Usage

Declare NgxFileParserConfig object to provide to the directive

NgxFileParserConfig has the following properties

| Property | Description | Default | | ------------------ | ------------------------------------------------------------------------------- | ----------- | | btnText | Text to be displayed on button | Choose file | | btnIcon | Material icon to be displayed on button | backup | | btnColor* | Color accent to the button | transparent | | accepts | Array of file name extensions | ['.csv'] | | csvNamedProperties | If parsed CSV file should be returned as array of objects with named properties | false |

*See Angular Material buttons for accents

Example

import { NgxFileParserConfig } from "ngx-file-parser";

ngxFileParserConfig: NgxFileParserConfig = {
  btnText: "Upload",
  btnIcon: "backup",
  btnColor: "primary",
  accepts: [".csv"],
  csvNamedProperties: true,
};

Use the ngx-file-btn directive and provide the needed config object and event listener function to handle the parsed object

<ngx-file-btn
  [(config)]="ngxFileParserConfig"
  (parsedFile)="handleParsedFile($event)"
></ngx-file-btn>

ngx-file-btn has the following output events

| Event | Description | Type | | ---------- | ------------------------------ | ---------- | | parsedFile | The result of the parsed file. | INgxResult | | processing | If the file is being processed | boolean |

export interface INgxResult {
  extension: string;
  result: INgxCsv | INgxJson | INgxComplexCsv;
}

Returns

All parsed object is returned as INgxResult with the extension of the file and a result object and is emitted to this event listener with the $event containing the parsed object

  handleParsedFile(parsedFileObj: INgxResult) {
    this.parsedFile = parsedFileObj.result as INgxCsv | INgxJson | INgxComplexCsv;
  }

CSV

Returns the interface INgxCsv with properties | Property | Description | | -------- | ----------------| | headers | Array of strings | | data | Array of arrays of string |

CSV Named Properties

Returns the interface INgxComplexCsv with properties | Property | Description | | -------- | ----------------| | [key: string]: string; | Property as definied in the upload CSV |

JSON

Returns the interface INgxJson with the properties that are definied in the upload JSON file

Contribute

All PR's, issues and contributors are welcome! Feel free to start contributing

License

MIT