$120 tested Claude codes · real before/after data · Full tier $15 one-timebuy --sheet=15 →
$Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. download --free →
clskills.sh — terminal v2.4 — 2,347 skills indexed● online
[CL]Skills_
Data & Analyticsbeginner

Data Exporter

Share

Export data in multiple formats

Works with OpenClaude

You are a data export specialist. The user wants to export data from various sources into multiple formats (JSON, CSV, XML, YAML) with validation and error handling.

What to check first

  • Verify you have the papaparse library for CSV: npm list papaparse
  • Check that js-yaml is installed for YAML support: npm list js-yaml
  • Confirm your data source is accessible (array, file path, or database connection)

Steps

  1. Install required dependencies: npm install papaparse js-yaml xml2js
  2. Import the DataExporter class and instantiate it with your source data
  3. Call the appropriate export method based on your target format (.toJSON(), .toCSV(), .toXML(), .toYAML())
  4. Handle the returned Promise and check for validation errors in the errors property
  5. Write the exported string to a file using fs.writeFileSync() or stream it to a response object
  6. Validate the output format by parsing it back and comparing field counts
  7. Log export metadata including row count, format, and file size
  8. Implement custom field mapping if your data structure needs transformation before export

Code

const fs = require('fs');
const Papa = require('papaparse');
const YAML = require('js-yaml');
const xml2js = require('xml2js');

class DataExporter {
  constructor(data) {
    this.data = Array.isArray(data) ? data : [data];
    this.errors = [];
  }

  toJSON(pretty = true) {
    try {
      return pretty ? JSON.stringify(this.data, null, 2) : JSON.stringify(this.data);
    } catch (error) {
      this.errors.push(`JSON export failed: ${error.message}`);
      return null;
    }
  }

  toCSV() {
    try {
      if (this.data.length === 0) {
        this.errors.push('Cannot export empty dataset to CSV');
        return null;
      }
      return Papa.unparse(this.data, {
        header: true,
        dynamicTyping: false,
        skipEmptyLines: true
      });
    } catch (error) {
      this.errors.push(`CSV export failed: ${error.message}`);
      return null;
    }
  }

  toYAML() {
    try {
      return YAML.dump(this.data, { indent: 2, lineWidth: -1 });
    } catch (error) {
      this.errors.push(`YAML export failed: ${error.message}`);
      return null;
    }
  }

  async toXML(rootElement = 'root', itemElement = 'item') {
    try {
      const builder = new xml2js.Builder({ rootName: rootElement });
      const xmlObject = { [itemElement]: this.data };

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

Difficultybeginner
Version1.0.0
AuthorClaude Skills Hub
dataexportformats

Install command:

curl -o ~/.claude/skills/data-exporter.md https://claude-skills-hub.vercel.app/skills/data/data-exporter.md

Related Data & Analytics Skills

Other Claude Code skills in the same category — free to download.

Want a Data & Analytics skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.