Tsallaka zuwa abun ciki
Justice Tech School

Reading and Writing CSV

read.csv reads a file and write.csv writes one. Use text = to read from a string.

Example
csv <- "name,score\nAda,92\nKofi,78"
df <- read.csv(text = csv)
print(df)
f <- tempfile(fileext = ".csv")
write.csv(df, f, row.names = FALSE)
print(readLines(f))
unlink(f)

Exercise

Write a file.

.csv(df, "f.csv")

Quiz Test

What does row.names = FALSE do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.