Unified data processing and format detection (CSV, JSON, Excel) with Result types for Trailhead System
npm install @trailhead/data> Data processing for CSV, JSON, and Excel with Result-based error handling



Unified data processing for CSV, JSON, and Excel formats with automatic format detection, conversion, and streaming support.
``bash`
pnpm add @trailhead/data
`typescript
import { data } from '@trailhead/data'
// Auto-detect and parse any supported format
const result = await data.parseAuto('./data.csv')
if (result.isOk()) {
console.log('Data:', result.value.data)
console.log('Format:', result.value.format)
}
// Write data in any format
await data.writeAuto('./output.json', myData)
`
- Unified API - Single interface for CSV, JSON, and Excel formats
- Auto-detection - Automatic format detection from file content
- Format conversion - Convert between all supported formats
- Streaming support - Process large files efficiently
- Result-based - Explicit error handling with Result types
`typescript
import { data } from '@trailhead/data'
// Auto-detect and parse
await data.parseAuto(filePath)
await data.parseAutoFromContent(content, hint?)
// Auto-detect and write
await data.writeAuto(filePath, data)
`
`typescript
import { createCSVOperations, createJSONOperations, createExcelOperations } from '@trailhead/data'
// CSV
const csv = createCSVOperations()
await csv.parseFile(path)
await csv.writeFile(data, path) // Note: data first, then path
// JSON
const json = createJSONOperations({ prettify: true })
await json.parseFile(path)
await json.writeFile(path, data)
// Excel
const excel = createExcelOperations()
await excel.parseFile(path)
await excel.writeFile(path, { sheets: [...] })
`
`typescript
import { createConversionOperations } from '@trailhead/data/formats/conversion'
const converter = createConversionOperations()
await converter.convert(source, target, { from: 'csv', to: 'json' })
``
- API Documentation - Complete API reference
- Data Pipeline Processing - Tutorial
- Convert Data Formats - How-to guide
MIT © esteban-url