[R] reading multiple XML files into an R table
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 4.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_after100/effect_after stationVinje/station affected_unitsG1, G2, G3/affected_units - # umm predecessor_id=*0* parent_id=*5244* new_followup=*New*u_id =*5244* event_start19.07.04 hour 11:15/event_start registered19.07.04 hour 11:15/registered event_typeProduction failure/event_type statusApproved and does not have a Followup/status decission19.07.04 hour 11:15/decission event_stop / predefined_remark / approved19.07.04 hour 11:17/approved affected_areasNO1/affected_areas remarksFailure G2, unavailable until further notice./remarks companyStatkraft SF/company /umm effect_before100/effect_before affected_fuelsHydro/affected_fuels effect_during0/effect_during prodconsProduction/prodcons effect_installed300/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@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.
Re: [R] reading multiple XML files into an R table
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.ho...@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 4.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_after100/effect_after stationVinje/station affected_unitsG1, G2, G3/affected_units - # umm predecessor_id=*0* parent_id=*5244* new_followup=*New*u_id =*5244* event_start19.07.04 hour 11:15/event_start registered19.07.04 hour 11:15/registered event_typeProduction failure/event_type statusApproved and does not have a Followup/status decission19.07.04 hour 11:15/decission event_stop / predefined_remark / approved19.07.04 hour 11:17/approved affected_areasNO1/affected_areas remarksFailure G2, unavailable until further notice./remarks companyStatkraft SF/company /umm effect_before100/effect_before affected_fuelsHydro/affected_fuels effect_during0/effect_during prodconsProduction/prodcons effect_installed300/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@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 __ 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.
Re: [R] reading multiple XML files into an R table
for the loop part: put all your xml files in a directory with no other files, do setwd(directory/with/xml/files) files - list.files() for (file in files) processs the files kjetil 2010/10/27 Ista Zahn iz...@psych.rochester.edu: 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.ho...@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 4.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_after100/effect_after stationVinje/station affected_unitsG1, G2, G3/affected_units - # umm predecessor_id=*0* parent_id=*5244* new_followup=*New*u_id =*5244* event_start19.07.04 hour 11:15/event_start registered19.07.04 hour 11:15/registered event_typeProduction failure/event_type statusApproved and does not have a Followup/status decission19.07.04 hour 11:15/decission event_stop / predefined_remark / approved19.07.04 hour 11:17/approved affected_areasNO1/affected_areas remarksFailure G2, unavailable until further notice./remarks companyStatkraft SF/company /umm effect_before100/effect_before affected_fuelsHydro/affected_fuels effect_during0/effect_during prodconsProduction/prodcons effect_installed300/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@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 __ 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. __ 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.