venkata kirankumar
2010-Jun-22 13:00 UTC
[R] Problem with writing a CSV file in UTF-8 formate
Hi all, I have a problem with writing a *.CSV file in UTF-8 formate I tried to write a dataframe named "dfPREINDX" to the new file named "preindx.csv" in below formate write.table(dfPREINDX,PreIndex,fileEncoding="UTF-8",sep="|",row.names=FALSE) but its throed an error like Error in write.table(dfPREINDX, "preindx.csv", fileEncoding = "UTF-8", sep "|", : unused argument(s) (fileEncoding = "UTF-8") can any one please help me how to create a file in UTF-8 formate. Thanks in advance kiran. [[alternative HTML version deleted]]
If you look at the help for write.table you will see that there is no 'fileEncoding' parameter. I would suggest you use a connection ('file') where you can specify the encoding. On Tue, Jun 22, 2010 at 9:00 AM, venkata kirankumar <kiran4u2all at gmail.com> wrote:> Hi all, > I have a problem with writing a *.CSV file in UTF-8 formate > > I tried to write a dataframe named ?"dfPREINDX" to the new file named > "preindx.csv" in below formate > > write.table(dfPREINDX,PreIndex,fileEncoding="UTF-8",sep="|",row.names=FALSE) > > but its throed an error ?like > > Error in write.table(dfPREINDX, "preindx.csv", fileEncoding = "UTF-8", sep > "|", ?: > ?unused argument(s) (fileEncoding = "UTF-8") > > can any one please help me how to create a file in UTF-8 ?formate. > > > Thanks in advance > kiran. > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?
Shotwell, Matthew S
2010-Jun-22 13:23 UTC
[R] Problem with writing a CSV file in UTF-8 formate
This should do it: out <- file("preindx.csv", "w", encoding="UTF-8") write.table(dfPREINDX, out, sep="|", row.names=FALSE) close(out) However, I believe that using "|" as a field separator makes this NOT a comma separated values (CSV) file, rather a "|" separated values file. -Matt ________________________________________ From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On Behalf Of venkata kirankumar [kiran4u2all at gmail.com] Sent: Tuesday, June 22, 2010 9:00 AM To: r-help at r-project.org Subject: [R] Problem with writing a CSV file in UTF-8 formate Hi all, I have a problem with writing a *.CSV file in UTF-8 formate I tried to write a dataframe named "dfPREINDX" to the new file named "preindx.csv" in below formate write.table(dfPREINDX,PreIndex,fileEncoding="UTF-8",sep="|",row.names=FALSE) but its throed an error like Error in write.table(dfPREINDX, "preindx.csv", fileEncoding = "UTF-8", sep "|", : unused argument(s) (fileEncoding = "UTF-8") can any one please help me how to create a file in UTF-8 formate. Thanks in advance kiran. [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
On 22/06/2010 9:00 AM, venkata kirankumar wrote:> Hi all, > I have a problem with writing a *.CSV file in UTF-8 formate > > I tried to write a dataframe named "dfPREINDX" to the new file named > "preindx.csv" in below formate > > write.table(dfPREINDX,PreIndex,fileEncoding="UTF-8",sep="|",row.names=FALSE) > > but its throed an error like > > Error in write.table(dfPREINDX, "preindx.csv", fileEncoding = "UTF-8", sep > "|", : > unused argument(s) (fileEncoding = "UTF-8") > > can any one please help me how to create a file in UTF-8 formate.The write.table has no fileEncoding argument. To write to a non-native encoding, you need to open a connection with that encoding, and write to that. For example: con <- file("preindx.csv", open="w", encoding="UTF-8") write.table(dfPREINDX, con, sep="|",row.names=FALSE) close(con) Duncan Murdoch