Read file exported from Microft SQL 2016

1

I received an exported Microsoft SQL 2016 file that has a .txt extension and the same file with .csv and looks like this:

I searched, but I still have not found anything, does anyone have any experience in importing this file into R?

A simple read.csv for example does not work

    
asked by anonymous 17.10.2017 / 15:09

1 answer

1

In theory, any .txt file can be imported into R . Try running the

dados <- read.table(file="NomeDoArquivo.txt", header=TRUE, sep="\t")

where

  • file="NomeDoArquivo.txt" is the name of the file to be imported

  • header=TRUE informs you that NomeDoArquivo.txt has a header. If NomeDoArquivo.txt does not have header, change argument to header=FALSE

  • sep="\t" is the file's column separator. Since read.csv is not working, I guess the column separator is a tab stop. Other common options for sep are , , ; and " " (space).

Finally, run

dim(dados)
str(dados)

and see if the number of rows and columns reported is as expected and if the data type in each column is correct. If all goes well, the data set was imported correctly. If it does not work (or if the code above does not work), come back here to try to figure out what to do together.

    
17.10.2017 / 15:30