xmlutils.py icon indicating copy to clipboard operation
xmlutils.py copied to clipboard

Skip void elements and specific items values

Open loretoparisi opened this issue 8 years ago • 0 comments

In my xml, I have some nodes in the chosen tag that have no values, I would like to skip them:

A typical node is like this

<source>Yahoo Business</source><url>http://us.rd.yahoo.com/dailynews/rss/business/*http://story.news.yahoo.com/news?tmpl=story2 u=/nm/20040814/bs_nm/column_stocks_week_dc</url><title>Wall St. Pullback Reflects Tech Blowout (Reuters)</title><image>none</image><category>Business</category><description>Reuters - Wall Street's long-playing drama,\"Waiting for Google," is about to reach its final act, but its\stock market debut is ending up as more of a nostalgia event\than the catalyst for a new era.</description><rank>5</rank><pubdate>0000-00-00 00:00:00</pubdate>

and for some of them, I have that the category is "" or it has another value to skip. When I convert to csv doing like

xml2csv --input data/newsspace200.xml --output data/newsspace200_.csv --delimiter $'\t' --tag 'source'

I will get the rows with "" category columni.n the csv file. Is it possibile to skip then those columns?

loretoparisi avatar May 08 '17 08:05 loretoparisi