Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all <a href="https://stackoverflow.com/questions/90838/how-can-i-detect-the-encoding-codepage-of-a-text-file">based on more general question on StackOverflow</a> it is not possible to detect encoding of file in 100% certainty.</p> <p>I've struggle this many times and come to non-automatic solution:</p> <p>Use <code>iconvlist</code> to get all possible encodings:</p> <pre><code>codepages &lt;- setNames(iconvlist(), iconvlist()) </code></pre> <p>Then read data using each of them</p> <pre><code>x &lt;- lapply(codepages, function(enc) try(read.table("encoding.asc", fileEncoding=enc, nrows=3, header=TRUE, sep="\t"))) # you get lots of errors/warning here </code></pre> <p>Important here is to know structure of file (separator, headers). Set encoding using <code>fileEncoding</code> argument. Read only few rows.<br> Now you could lookup on results:</p> <pre><code>unique(do.call(rbind, sapply(x, dim))) # [,1] [,2] # 437 14 2 # CP1200 3 29 # CP12000 0 1 </code></pre> <p>Seems like correct one is that with 3 rows and 29 columns, so lets see them:</p> <pre><code>maybe_ok &lt;- sapply(x, function(x) isTRUE(all.equal(dim(x), c(3,29)))) codepages[maybe_ok] # CP1200 UCS-2LE UTF-16 UTF-16LE UTF16 UTF16LE # "CP1200" "UCS-2LE" "UTF-16" "UTF-16LE" "UTF16" "UTF16LE" </code></pre> <p>You could look on data too</p> <pre><code>x[maybe_ok] </code></pre> <p>For your file all this encodings returns identical data (partially because there is some redundancy as you see).</p> <p>If you don't know specific of your file you need to use <code>readLines</code> with some changes in workflow (e.g. you can't use <code>fileEncoding</code>, must use <code>length</code> instead of <code>dim</code>, do more magic to find correct ones).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload