?
Solved

Data to XML

Posted on 2010-09-20
6
Medium Priority
?
700 Views
Last Modified: 2013-11-15
Hi,

I'm looking for a way to convert a list of domain lists to XML format.

Example:

domain.com     number    number     number     number
domain.com     number    number     number     number
domain.com     number    number     number     number
domain.com     number    number     number     number
domain.com     number    number     number     number
domain.com     number    number     number     number

Desired Output:

                <tr class="gradeA">
                  <td>domain</td>
                  <td>number</td>
                  <td>number</td>
                  <td class="center">number</td>

                  <td class="center">number</td>
            </tr>
      <tr class="gradeA">
                  <td>domain</td>
                  <td>number</td>
                  <td>number</td>
                  <td class="center">number</td>

                  <td class="center">number</td>
            </tr>
      <tr class="gradeA">
                  <td>domain</td>
                  <td>number</td>
                  <td>number</td>
                  <td class="center">number</td>

                  <td class="center">number</td>
            </tr>
      <tr class="gradeA">
                  <td>domain</td>
                  <td>number</td>
                  <td>number</td>
                  <td class="center">number</td>

                  <td class="center">number</td>
            </tr>

Thank you
0
Comment
Question by:faithless1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 33722826
awk 'print awk '{print "<tr class=\"gradeA\">\n<td>"$1"</td>\n<td>"$2"</td>\n<td>"$3"</td>\n<td class=\"center\">"$4"</td>\n<td class=\"center\">"$5"</td>"}'
0
 
LVL 84

Expert Comment

by:ozo
ID: 33722827
awk '{print "<tr class=\"gradeA\">\n<td>"$1"</td>\n<td>"$2"</td>\n<td>"$3"</td>\n<td class=\"center\">"$4"</td>\n<td class=\"center\">"$5"</td>"}'
0
 
LVL 15

Expert Comment

by:mish33
ID: 33726218

#!/usr/bin/python
import sys
for line in open(sys.stdin):
  domain, n1, n2, n3, n4 = line.split()
  print '''\
           <tr class="gradeA">
                  <td>%s</td>
                  <td>%s</td>
                  <td>%s</td>
                  <td class="center">%s</td>

                  <td class="center">%s</td>
            </tr>
''' % (domain.rsplit('.', 1)[0], n1, n2, n3, n4)

Open in new window

0
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
LVL 84

Accepted Solution

by:
ozo earned 2000 total points
ID: 33727437
perl -ane 'printf q(   <tr class="gradeA">
                  <td>%s</td>
                  <td>%s</td>
                  <td>%s</td>
                  <td class="center">%s</td>

                  <td class="center">%s</td>
            </tr>
),@F'  
0
 
LVL 15

Expert Comment

by:mish33
ID: 33728363
.com not cut away :)
0
 
LVL 84

Expert Comment

by:ozo
ID: 33731244
perl -ane '$F[0]=~s/\.com$//;printf q(   <tr class="gradeA">
                  <td>%s</td>
                  <td>%s</td>
                  <td>%s</td>
                  <td class="center">%s</td>

                  <td class="center">%s</td>
            </tr>
),@F'  
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question