Hi, Here i have a csv file, it contain like this NAME UPDATED --------- -------------- ABC INDIA XYZ UK My requirement what is, i need to change the value inside the csv file (instead of INDIA i need to make it USA). NAME UPDATED --------- -------------- ABC USA XYZ UK How can we update by writing into the csv file ? i dont want to delete entire data and write data from dataframe into csv - like that. I need direct file update ! Any help ? - Thanks in advance ! Antony -- View this message in context: http://r.789695.n4.nabble.com/Update-CSV-file-content-tp4645409.html Sent from the R help mailing list archive at Nabble.com.
Mr Akkara, On 8 October 2012 05:20, Rantony <antony.akkara@ge.com> wrote:> > Here i have a csv file, it contain like this > > NAME UPDATED > --------- -------------- > ABC INDIA > XYZ UK > > My requirement what is, i need to change the value inside the csv file > (instead of INDIA i need to make it USA). > > NAME UPDATED > --------- -------------- > ABC USA > XYZ UK > >How about:> read.data(csv-file-name, header=TRUE, stringsAsFactors=FALSE) ->nameAndUpdated> nameAndUpdated[nameAndUpdated[,2] == 'USA',2] <- 'INDIA' > write.csv(nameAndUpdated, csv-file-name, header=TRUE)-- Sent from my mobile device Envoyait de mon portable [[alternative HTML version deleted]]
On 10/08/2012 08:20 PM, Rantony wrote:> Hi, > > Here i have a csv file, it contain like this > > NAME UPDATED > --------- -------------- > ABC INDIA > XYZ UK > > My requirement what is, i need to change the value inside the csv file > (instead of INDIA i need to make it USA). > > NAME UPDATED > --------- -------------- > ABC USA > XYZ UK > > > How can we update by writing into the csv file ? i dont want to delete > entire data and write data from dataframe > into csv - like that. I need direct file update !Hi Antony, If it's a small CSV file, you can just alter it in a text editor. Otherwise, that's what spreadsheets are for. Jim