szuru2shimmie2/translate.nim

27 lines
685 B
Nim

import std/parsecsv
import std/os
var postTags: CsvParser
var tagNames: CsvParser
removeFile("post_ids_with_named_tags.csv")
###Translate Them###
postTags.open("post_tags.csv")
tagNames.open("tag_names.csv")
var f = open("post_ids_with_named_tags.csv", fmAppend)
f.writeLine("post_id,tag_name")
postTags.readHeaderRow()
while postTags.readRow():
tagNames.readHeaderRow()
while tagNames.readRow():
if postTags.rowEntry("tag_id") == tagNames.rowEntry("tag_id"):
f.writeLine(postTags.rowEntry("post_id") & "," & tagNames.rowEntry("name"))
echo (postTags.rowEntry("post_id") & "," & tagNames.rowEntry("name"))
tagNames.close()
tagNames.open("tag_names.csv")