Maybe you can use ',=' as separators. ( I don't have R to check).
Otherwise, I would clean the file with an editor or tool like 'sed' to
replace the regular expression /key[0-9]=/ by nothing.
On Jan 18, 2013 8:05 AM, "Frank Singleton" <b17fly...@gmail.com> wrote:

> Hi,
>
> Thanks for a great environmentfor statistical  computing :-)
>
> I have some input data in a file ("input_kvpairs.csv") of the form
>
> key1=23, key2=67, key3="hello there"
> key1=7, key2=22, key3="how are you"
> key1=2, key2=77, key3="nice day, thanks"
>
> Now in my head I wish it was of the form ("input.csv")
>
> #key1, key2, key3
> 23,    67,   "hello there"
> 7,     22,   "how are you"
> 2,     77,   "nice day, thanks"
>
> so I could do
>
> data <- read.csv("input.csv", header=TRUE)
>
> where the header column names are derived from the key names dynamically,
> and I could access the data using normal data$key1 or data$key2 mechanism.
>
> I guess I could just pre process the file first  using python etc to create
> a CSV file with column header derived from key names, and values derived
> from
> key values, but I am interested to see how experienced R folks would
> handle this
> inside R.
>
> Thanks,
>
> Frank
>
> ______________________________**________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
> PLEASE do read the posting guide http://www.R-project.org/**
> posting-guide.html <http://www.R-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to