Skip to content
csv-to-apkg / 1.1.6

csv-to-apkg 1.1.6

Install from the command line:
Learn more about npm packages
$ npm install @2anki/csv-to-apkg@1.1.6
Install via package.json:
"@2anki/csv-to-apkg": "1.1.6"

About this version

CSV to APKG

A small library to convert CSV files to APKG files.

Dependencies

This project is part of 2anki.net and uses the following dependencies:

Make sure these projects are available one level above this project:

git clone https://github.com/2anki/2anki.net ../server
git clone https://github.com/2anki/create_deck ../create_deck

Install

npm i @2anki/csv-to-apkg

Usage

Below is an example showing you how to convert your csv (string).

import convertCSVToAPKG from '@2anki/csv-to-apkg';

const csvContent = `Front,Back
What is the capital of Germany?,Berlin`;

convertCSVToAPKG(csvContent); // Promise<Buffer>

import fs from 'fs';
import os from 'os';

import resolvePath from '../filesystem/resolvePath';
import Workspace from '../filesystem/Workspace';
import APKGExporter from '../filesystem/APKGExporter';
import convertCSVToAPKG from '../convertCSVToAPKG';

const workspace = new Workspace(os.tmpdir());
const exporter = new APKGExporter('Default', workspace.location);

const csvFile = fs
    .readFileSync(
        resolvePath(
            __dirname,
            '../mocks/Japanese Words 71594f63607d440fa080879385ec0acc.csv'
        ),
        'utf-8'
    )
    .toString();

/* eslint-disable no-console */
console.log('workspace.location', workspace.location);
convertCSVToAPKG(csvFile, exporter)
    .then(() => {
        console.log('Files available at: ', workspace.location);
        console.info('Done!');
    })
    .catch(console.error);

How does it work?

csv-to-apkg reads your comma delimited data. It takes the first column and treats it as the front of the card. The remaining columns are the back of the card.

Limitations

Cloze deletion are not supported.

License

Unless otherwise specified in the source:

The code is licensed under the MIT Copyright (c) 2023, Alexander Alemayhu.

Details


Assets

  • csv-to-apkg-1.1.6.tgz

Download activity

  • Total downloads 0
  • Last 30 days 0
  • Last week 0
  • Today 0

Recent versions

View all