Skip to content

Instantly share code, notes, and snippets.

@battis
Created January 21, 2026 19:25
Show Gist options
  • Select an option

  • Save battis/d70e8d814c92acd4d609c5d9b45182bf to your computer and use it in GitHub Desktop.

Select an option

Save battis/d70e8d814c92acd4d609c5d9b45182bf to your computer and use it in GitHub Desktop.
Convert a CSV of HTML snippets into a CSV of plain text snippets
import { parse } from 'csv-parse/sync';
import { convert } from 'html-to-text';
import { stringify } from 'csv-stringify/sync';
import fs from 'node:fs';
const courses = parse(
fs.readFileSync('/Users/sbattis/Downloads/courses.csv'),
{
columns: true
}
);
const txt = courses.map(
course => ({
'Course ID': course['Course ID'],
Description: convert(
course.Description,
{
wordwrap: false
}
)
})
);
fs.writeFileSync(
'/Users/sbattis/Downloads/coures-txt.csv',
stringify(
txt,
{
header: true
}
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment