我正在将CSV
文件转换为RDS
。然后,我将转换后的RDS
文件转换回CSV
,只是为了检查转换是否正确。但是在反向转换后,某些行被删除了。此外,某些字符的格式已更改。如何将CSV
正确转换为RDS
?
CSV(从tss.csv
转换为tss.RDS
之前):
zipcode centile superzip rank city.x state.x adultpop households college income latitude longitude country
1001 60.37489 0 6115 Agawam MA 12293 4219 0.2206947 73.40212 33.7252151 73.0546241 Street 14, F-7/2, E-7, ICT, وفاقی دارالحکومت اسلام آباد, 44000, پاکستان
1002 93.69713 0 975 Amherst Nust Link Road, H-11, ICT, ????? ?????????? ????? ????, 44000, ????????? 14232 5081 0.6852867 82.63116 33.6492414 72.999878 Nust Link Road, H-11, ICT, وفاقی دارالحکومت اسلام آباد, 44000, پاکستان
1005 58.31555 0 6511 Barre MA 3348 1400 0.2051971 73.19553 33.6810126 72.9779288 Service Road West F11, E-11/1, E-11, ICT, وفاقی دارالحکومت اسلام آباد, 44000, پاکستان
CSV(从tss.RDS
转换为tss.csv
后):
X.ff..fe.zipcode centile superzip rank city.x state.x adultpop households college income latitude longitude country
1002 93.69713 0 975 Amherst Nust Link Road, H-11, ICT, ????? ?????????? ????? ????, 44000, ????????? 14232 5081 0.6852867 82.63116 33.6492414 72.999878 "Nust Link Road, H-11, ICT, HA'BÌ /'1'D-©HE* '3D'E ('/, 44000, ~'©3*'F
1005 58.31555 0 6511 Barre MA 3348 1400 0.2051971 73.19553 33.6810126 72.9779288 Service Road West F11, E-11/1, E-11, ICT, HA'BÌ /'1'D-©HE* '3D'E ('/, 44000, ~'©3*'F "
为什么在转换时出现此错误?如何将CSV
正确转换为RDS
?有什么建议吗?
代码:
fil<-read.csv("D:/PycharmProjects/tss.csv", header = TRUE, sep="\t", encoding="UTF-8", skipNul = T)
export(fil,"D:/PycharmProjects/tss.rds")
fil<-readRDS("D:/PycharmProjects/tss.RDS")
export(fil,"D:/PycharmProjects/tss.csv")