[R] Read a csv file

P Ehlers ehlers at math.ucalgary.ca
Fri Feb 17 00:25:02 CET 2006


Alexandra,
I haven't seen an answer to your query yet, so let me give it a shot.

First, I would not use R-illegal variable names (I assume you
want 2004-12-30, etc, to be your colnames). Try replacing them
with A,B,C, etc. And delete the empty string at the start.

Then I would make sure that there are linefeeds before "091529",
etc, which I assume are your rownames.

Finally, I would use
  temp <- read.csv("the csv adress")
which will default to header = TRUE, etc.

And if that works for you (it did for me) I would check the
402111632.57 value for possible error.

Here's an abbreviated version of your file that you can test:

A,B,C,D
091529,,40797616.82,40512773.17,40476284.73
091553,,24908681.74,24814586.13,
091571,,12931770.37,12868282.58,12893857.63
091502,,54336162.2999999,54151915.56,53822069.82
126731,,26059305.54,25972063.79,25893131.09


(BTW: I don't see how you were able to read the file that you
say you could read.)

Peter Ehlers


Alexandra R. M. de Almeida wrote:
> Dear R users,
>  
>  I have 14 csv's files that I want read in R, but one of them I can't read (the others 13 don't bring me any problem), and I don't know the problem. I will report the subject of the csv that I can't read, one csv that don't have any problem to read and the script that I use to try do it.
>  
>  CSV THAT I CAN'T READ:
>  *****************************
>        
> "",2004-12-30,2005-01-31,2005-02-28,2005-03-31,2005-04-29,2005-05-31,2005-06-30,2005-07-29,2005-08-31,2005-09-30,2005-10-31,2005-11-30,2005-12-29 091529,,40797616.82,40512773.17,40476284.73,40468557.11,,40437955.3400001,402111632.57,40571892.91,41019554.17,41318962.85,41318962.85, 091553,,24908681.74,24814586.13,,24803248.1,,24788910.05,24779821.29,24752903.91,24734282.39,24751532.07,24689283.78, 091571,,12931770.37,12868282.58,12893857.63,12876237.31,,12849139.41,12813254.18,12805919.98,12732718.7,12750495.16,12723562.95,12699066.57 091502,,54336162.2999999,54151915.56,53822069.82,53485186.1,,53032321.02,53489126.7,53366494.63,53207248.99,52967831.22,52722932.14,53837934.11 126731,,26059305.54,25972063.79,25893131.09,25848060.97,,25693215.97,25608393.62,25457521.32,25369733.73,25254490.23,25136883.19,25039982.16 
> 
>  ONE CSV THAT I CAN READ:
>  *********************************
>        
> "",2004-12-30,2005-01-31,2005-02-28,2005-03-31,2005-04-29,2005-05-31,2005-06-30,2005-07-29,2005-08-31,2005-09-30,2005-10-31,2005-11-30,2005-12-29 118214,6311825.94,5864148.03,5936471.99,5982408.92,5566445.03,5910110,5794680.19,6120773.65,6475695.29,5885656.58,5985008.26,6281223.36,6525932 085472,5770636.05,5637700.86,6128119.74,6271170.01,5613857.19,5094923.46,5057774.93,5353204.26,5460109.01,4731991.51,4847440.19,4532212.61,4237428.03 104231,22008340.08,21376713.76,24301057.75,24424624.42,23915639.41,21113516.09,21111603.24,21873741.8599999,21472396.03,22129567.97,22714447.7,21724517.05,22269561.09 097314,12467272.83,11100942.53,10430991.59,10107819.21,10555168.79,9637592.69,8638577.35,9524544.24,11182677.41,10308354.31,10320002.7,10147418.26,10771015.05 112925,3705133.34,3669389.26,3813722.34,3435817.19,3160329.46,2761649.16,2646939.68,3580033.72,3632261.84,3542923.69,3589498.79,3514793.31,4200379.2
>  086908,6437832.97,6736435.08,6892230.99,5672582.08,6449993.07,5846420.84,4556138.4,4880862.17,4884144.73,4452288.98,4636981.93,5879802.29,6088802.67 132616,1474667.34,1395177.12,1436053.42,1441598.54,470946.89,313116.01,298916.55,307676.31,307406.3,282800.37,284073.67,275566.91,293621.71 118222,6325973.54,5876657.44,5947610.25,5996347.04,5577943.77,5922848.59,5807960.45,6131649.57,6488493.15,5898377.27,5995776.67,6292922.68,6539705.86 097306,10760666.38,9491069.59,8806083.49,8472799.11,7942297.05,7264294.84,7343883.52,8197608.09,8738058.8,7902283.01,8233148.09,8153610.13,8659006.06 087319,1564390.36,1270270.63,1338154.93,1271605.04,1180629.89,1064629.09,1016657.74,3294460.82,3352300.22,805828.7,813883.24,788913.5,831963.24 103780,24756764.0300001,23452918.28,27679174.61,27923631.4,26402941.87,23999304.74,23222666.2000001,25423020.13,25628153.03,23171390.37,25056699.82,24319389.27,27290279.5699999 091456,354883.36,290394.31,291068.59,292289.11,274028.35,249202.14,237436.27
,,!
>  ,,,,
>  145033,,,,3534246.56,2828620.7,2107164.76,2499778.98,3501569.65,2822563.6,2719116.36,3125764.52,2463544.64,2624246.15 101621,1716754.85,1621736.71,1631089.63,1641090.36,2620765.11,2383375.75,1294499.03,1326391.79,2443147.47,2404299.33,2090743.45,1997445.59,2118693.45 
> 
>  SCRIPT:
>  *********
>        
> temp<-read.table("the csv adress",header=T,row.names=1,sep=",",dec=".")
> 
>  Thank's
>  
>  Alexandra Almeida
>  
>  
> 
> 
>   Alexandra R. Mendes de Almeida
> 
>                                                  
> 
> 
> 		
> ---------------------------------
> 
> Internet rápida e grátis. Instale o discador agora!
> 	[[alternative HTML version deleted]]
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




More information about the R-help mailing list