Skip to content

**Amazon Textract Response to CSV** export tables and extract `key-value` pairs in form documents from `JSON` returned by Amazon Textract into a comma-separated values (CSV) file.

License

Notifications You must be signed in to change notification settings

JoeDalton24/amazon-textract-response-tocsv

Repository files navigation

Amazon Textract Response to CSV 🧩

Amazon Textract Response to CSV export tables and extract key-value pairs in form documents from JSON returned by Amazon Textract into a comma-separated values (CSV) file. This module work both with ESM and CommonJs

Made-In-Senegal

Export tables from JSON returned by Amazon Textract ✅

import { writeTables } from "amazon-textract-response-tocsv";

const analyze_document_text = async () => {
  try {
    const analyzeDoc = new AnalyzeDocumentCommand(params);
    const response = await textractClient.send(analyzeDoc);

    //call writeTables with the response
    await writeTables(response);
  } catch (err) {
    console.log("Error", err);
  }
};

How to use writeTables ✅

The writeTables function of Amazon Textract Response to CSV take one parameters the JSON returned by Amazon Textract.
And then exports data in an file named : tables_output.csv

import with esm

import { writeTables, writeKeyValuePair } from "amazon-textract-response-tocsv";

await writeTables(response);

import with commonjs

const {
  writeTables,
  writeKeyValuePair,
} = require("amazon-textract-response-tocsv");

await writeTables(response);

Export key-value pairs from JSON returned by Amazon Textract ✅

import { writeKeyValuePair } from "amazon-textract-response-tocsv";

const analyze_document_text = async () => {
  try {
    const analyzeDoc = new AnalyzeDocumentCommand(params);
    const response = await textractClient.send(analyzeDoc);

    //call writeKeyValuePair with the response
    await writeKeyValuePair(response);
  } catch (err) {
    console.log("Error", err);
  }
};

How to use writeKeyValuePair ✅

The writeKeyValuePair function just like the writeTables function of Amazon Textract Response to CSV takes one parameters the JSON returned by Amazon Textract.
The only difference is that the exported file will be named : key_value_output.csv

await writeKeyValuePair(response);

License 🎫

This project is released under the MIT License

About

**Amazon Textract Response to CSV** export tables and extract `key-value` pairs in form documents from `JSON` returned by Amazon Textract into a comma-separated values (CSV) file.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published