Created
September 10, 2020 14:48
-
-
Save danopia/ab549db45c0a0604c9b242ac093b00d3 to your computer and use it in GitHub Desktop.
Small Deno tools
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
// In a Unix pipe, accepts 'tableized' input with many spaces between fields, | |
// and outputs the data as a traditional CSV. | |
// Does not handle input where fields contain their own spaces. | |
import { BufReader, BufWriter } from "https://deno.land/[email protected]/io/bufio.ts"; | |
import { TextProtoReader } from "https://deno.land/[email protected]/textproto/mod.ts"; | |
const input = new TextProtoReader(new BufReader(Deno.stdin)); | |
while (true) { | |
const line = await input.readLine(); | |
if (line === null) { | |
break; | |
} else { | |
console.log(line.replace(/ +/g, ',')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment