Created
January 21, 2026 19:25
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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