Reputation: 801
I have big problems in reading this file:
It was a .csv when I read it in the first time:
files = list.files(pattern=".csv")
df = read.csv(files[1],header = TRUE, sep=";")
Then I saved it like this (this is the file from the link)
file_name <- paste ("df.dat", col="", sep="")
write.table(df, file_name, row.names=TRUE, col.names=TRUE)
And now I fail to read it again. This is what I tried already:
files = list.files(pattern="df")
df = read.table(files[1],header = TRUE, sep=",")
df = read.table(files[1],header = TRUE, sep=";")
df = read.table(files[1],header = TRUE, sep="")
df = read.table(files[1],header = TRUE, sep=".")
df = read.table(files[1],header = TRUE)
df = read.csv(files[1],header = TRUE, sep=";")
df = read.csv(files[1],header = TRUE, sep=",")
df = read.csv(files[1],header = TRUE, sep="")
Any ideas how to solve this problem?
Upvotes: 1
Views: 765
Reputation: 2956
It seems there occurred a problem while transforming the csv to dat.
You can read a .dat file which is in csv format with read_table
So in you case: read.table("AUG-2017-NO2.dat", skip=1, row.names=1)
You have to skip a row since your column headers are less then columns. So you can try to save your csv correctly (which you fixed in the commentary; issue was the time stamps) or you change columns names afterwards with:
colnames(df) <- c("Date", "Time", "BourgesPlatz", "Karlstraße", "Königsplatz", "LfU")
The header=TRUE
argument did not work in your examples, since you had less header names then columns
Upvotes: 1