1.2.16 • Published 2 years ago

@tryghost/members-csv v1.2.16

Weekly downloads
10,331
License
MIT
Repository
github
Last release
2 years ago

Members Csv

Install

npm install @tryghost/members-csv --save

or

yarn add @tryghost/members-csv

Usage

There are 2 parts to this package: CSV to JSON serialization and JSON to CSV serialization. The module exposes 2 methods to fullfil these: parse and unparse respectively.

To parse CSV file and convert it to JSON use parse method, e.g.:

const {parse} = require('@tryghost/members-csv');

const mapping = {
    email: 'csv_column_containing_email_data',
    name: 'csv_column_containing_names_data'
}
const membersJSON = await parse(csvFilePath, mapping);

csvFilePath - is a path to the CSV file that has to be processed mapping - optional parameter, it's a hash describing custom mapping for CSV columns to JSON properties

Example mapping for CSV having email under correo_electronico column would look like following:

{
    email: 'correo_electronico'
}

To unparse JSON to CSV compatible with members format use following:

const {unparse} = require('@tryghost/members-csv');

const members = [{
    email: 'email@example.com',
    name: 'Sam Memberino',
    note: 'Early supporter'
}];

const membersCSV = unparse(members);

console.log(membersCSV);
// -> "id,email,name,note,subscribed_to_emails,complimentary_plan,stripe_customer_id,created_at,deleted_at,labels\r\n,email@example.com,Sam Memberino,Early supporter,,,,,,"

Develop

This is a mono repository, managed with lerna.

Follow the instructions for the top-level repo. 1. git clone this repo & cd into it as usual 2. Run yarn to install top-level dependencies.

Run

  • yarn dev

Test

  • yarn lint run just eslint
  • yarn test run lint and tests

Copyright & License

Copyright (c) 2013-2022 Ghost Foundation - Released under the MIT license.

1.2.13

2 years ago

1.2.16

2 years ago

1.2.14

2 years ago

1.2.15

2 years ago

1.2.12

2 years ago

1.2.10

2 years ago

1.2.11

2 years ago

1.2.8

2 years ago

1.2.9

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.0-rc.2

3 years ago

1.0.0-rc.1

3 years ago

0.4.5

3 years ago

1.0.0-rc.0

3 years ago

0.4.4

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.3

3 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago