[R] reading multiple XML files into an R table

Ista Zahn izahn at psych.rochester.edu
Wed Oct 27 15:27:24 CEST 2010


Hi Jørgen,
You will be better served by learning how to find the answers to these
kinds of questions on your own. You can either use a general search
engine such as google:
http://lmgtfy.com/?q=read+multiple+files+in+R
http://lmgtfy.com/?q=read+xml+data+in+R
or using an R specific search engine. At the R prompt, try
RSiteSearch("read multiple files", restrict=NULL)
RSiteSearch("read xml", restrict=NULL)

If you run into difficulties many people on this list (including
myself) will be happy to help.
Best,
Ista

2010/10/27 Jørgen Blystad Houge <jb.houge at gmail.com>:
> Good morning fellow R users!
>
> I need to read multiple .XML files now gathered in one folder and collect
> them in a table in R. The files have only numeric names and are named nearly
> continuously (e.g 1.xml, 2.xml, 3.xml ..... up to about 40000.xml) but with
> a few missing numbers/files. So the code must be able to handle missing
> files.
>
> Can someone suggest a FOR-loop in R that could be able to read all these
> files and categorize them correctly? I've pasted an example underneath. (For
> those interested, this is an "Urgent Market Message" on Nord Pool Spot. I
> would like to systematize them to observe the power market reserve margin as
> historic time series. That is estimate how much electricity is actually
> available for the market.
>
>  <?xml version="1.0" encoding="ISO-8859-1" ?>
>  - <#> <participant_umm>
>   <effect_after>100</effect_after>
>   <station>Vinje</station>
>   <affected_units>G1, G2, G3</affected_units>
>  - <#> <umm predecessor_id="*0*" parent_id="*5244*" new_followup="*New*"u_id
> ="*5244*">
>   <event_start>19.07.04 hour 11:15</event_start>
>   <registered>19.07.04 hour 11:15</registered>
>   <event_type>Production failure</event_type>
>   <status>Approved and does not have a Followup</status>
>   <decission>19.07.04 hour 11:15</decission>
>   <event_stop />
>   <predefined_remark />
>   <approved>19.07.04 hour 11:17</approved>
>   <affected_areas>NO1</affected_areas>
>   <remarks>Failure G2, unavailable until further notice.</remarks>
>   <company>Statkraft SF</company>
>  </umm>
>   <effect_before>100</effect_before>
>   <affected_fuels>Hydro</affected_fuels>
>   <effect_during>0</effect_during>
>   <prodcons>Production</prodcons>
>   <effect_installed>300</effect_installed>
>  </participant_umm>
>
> Thanks a lot!
>
> Best,
> Jørgen Blystad Houge
> MSc student Norwegian University of Science and Technology
>
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at 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.
>
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org



More information about the R-help mailing list