I read a csv file containing html code in its fields using fread
, do some maintenance on it and write the resulting datatable to a file using fwrite
Two possible solutions (using v1.10.0 of data.table):
1: Use the quote = FALSE
parameter:
fwrite(dt, 'fwrite.csv', quote = FALSE)
When opening the file in a text editor, you will see this:
htmlcode
<colspan="7">
<colspan="8">
2: Replace the double brackets with single one (as also suggeted by @joel.wilson in the comments):
dt[, htmlcode := gsub('\"', '\'', htmlcode)]
fwrite(dt, 'fwrite.csv')
When opening the file in a text editor, you will see this:
htmlcode
<colspan='7'>
<colspan='8'>