Can I download XML data from the web and save, in as CSV or TXT delimitation?
lac at openend.se
Wed Aug 19 15:51:16 CEST 2015
In a message of Wed, 19 Aug 2015 06:32:46 -0700, ryguy7272 writes:
>Well, yes, I was originally trying to do it it R, but I couldn't get
>it working, so I thought I'd try to do it in Python. That was a
>sample R script. Can I do essentially the same thing in Python? Can
>I read the XML from the web?
>Parse it, or clean it, or whatever, and save it as a CSV or TXT? Is
>that possible? Thanks. --
The question is, is this a reasonable thing to do. If your xml file is
flat, and simple, then moving to csv is easy, and a fine idea.
Python has tons of utilities for dealing with xml files.
download that and conversion is a simple as running the command line
xml2csv --input "samples/fruits.xml" --output "samples/fruits.csv" --tag "item"
But XML is designed for the representation of complex data -- if your
xmlfile has a lot of structure then a CSV file doesn't have enough
structure in itself to do a good job of holding the data.
xml2json -- you will get one of those too -- might give you a file that
you would find more suitable to use.
But there is a very good chance that you will have to analyse the
structure of your data, and parse it, and decide what to keep and what
you don't care about. Python is very, very good at doing this but
you will have to learn how to program in Python -- at least a little --
to do this. Have you programmed in Python before? In another language?
More information about the Python-list