Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R reading a tsv file using specific encoding

Tags:

r

tsv

I am trying to read a .tsv (tab-separated value) file into R using a specific encoding. It's supposedly windows-1252. And it has a header.

Any suggestions for the code to put it into a data frame?

like image 601
screechOwl Avatar asked Mar 19 '12 03:03

screechOwl


People also ask

What type of file is a TSV?

A tab-separated values (TSV) file is a text format whose primary function is to store data in a table structure where each record in the table is recorded as one line of the text file.

Can pandas read TSV?

TSV stands for Tab Separated File Use pandas which is a text file where each field is separated by tab (\t). In pandas, you can read the TSV file into DataFrame by using the read_table() function.


1 Answers

Something like this perhaps?

mydf <- read.table('thefile.txt', header=TRUE, sep="\t", fileEncoding="windows-1252")
str(mydf)
like image 56
Tommy Avatar answered Sep 20 '22 16:09

Tommy