Sponsored Content
Full Discussion: XML format
Top Forums Shell Programming and Scripting XML format Post 302433767 by fpmurphy on Wednesday 30th of June 2010 02:08:28 PM
Old 06-30-2010
Humm, As far as XML is concerned I think that the AverageTime element always needs to be included even if it is empty i.e.
Code:
<label>
  <Date>2010-06-02</Date>
  <ID>3</ID>
  <Name>30943</Name>
  <Time>00:00:50</Time>
  <Average Time>1.39</Average Time>
</label>
<label>
  <Date>2010-06-02</Date>
  <ID>1</ID>
  <Name>4545</Name>
  <Time>00:01:03</Time>
  <Average Time></Average Time>
</label>
<label>
  <Date>2010-06-02</Date>
  <ID>9</ID>
  <Name>8203</Name>
  <Time>00:01:00</Time>
  <Average Time></Average Time>
</label>



---------- Post updated at 02:08 PM ---------- Previous update was at 12:22 PM ----------

Here is another way of converting the CSV to XML using python
Code:
import csv

csv.register_dialect('custom', delimiter='\t', skipinitialspace=True)

ifile = file("file.csv")
data = csv.reader(ifile, dialect='custom')
tags = data.next()
l = len(tags);

with ifile:
    data = csv.reader(ifile, dialect='custom')
    print "<labels>"
    for record in data:
         print "  <label>"
         for i, field in enumerate(record):
             print "     <"+tags[i].strip('\'')+">"+field+"</"+tags[i].strip('\'')+">"
         i += 1
         while (i < len(tags)):
             print "     <"+tags[i].strip('\'')+"></"+tags[i].strip('\'')+">"
             i += 1
         print "  </label>"
    print "</labels>"

This outputs
Code:
<labels>
  <label>
     <Date>2010-06-02</Date>
     <ID>3</ID>
     <Name>30943</Name>
     <Time>00:00:50</Time>
     <Average Time>1.39</Average Time>
  </label>
  <label>
     <Date>2010-06-02</Date>
     <ID>1</ID>
     <Name>4545</Name>
     <Time>00:01:03</Time>
     <Average Time></Average Time>
  </label>
  <label>
     <Date>2010-06-02</Date>
     <ID>9</ID>
     <Name>8203</Name>
     <Time>00:01:00</Time>
     <Average Time></Average Time>
  </label>
</labels>

This User Gave Thanks to fpmurphy For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

format xml

i want to grep to a file the numerator-denominator, 1.23456, 1.78901 from the following xml tags. <locks:pair xc:value="numerator/denominator" xc:type="Fields"> <mp:formFactor>1</mp:formFactor> <mp:quotation>numerator-denominator</mp:quotation> <mp:one>1.23456</mp:one>... (5 Replies)
Discussion started by: sigh2010
5 Replies

2. Shell Programming and Scripting

Convert XML to CSV format

Can any one give the idea on this, please. I have the following XML file and wants to convert into CSV(comma separated value) format. <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE Waveset PUBLIC 'waveset.dtd' 'waveset.dtd'> <Waveset> <Object name='ra8736'> <Attribute name='ADDRESS'... (2 Replies)
Discussion started by: kumar04
2 Replies

3. Shell Programming and Scripting

how to parse the file in xml format using awk/nawk

Hi All, I have an xml file with the below format. <a>111</a><b>222</b><c>333<c><d><e>123</e><f>234</f><d><e>456</e><f>789</f> output needed is 111,222,333,123,234 111,222,333,456,789 nawk 'BEGIN{FS="<|>"} {print a,b,c,e,f a="" ... (7 Replies)
Discussion started by: natalie23
7 Replies

4. UNIX for Dummies Questions & Answers

XML / XSD: what is a good format for amounts?

Suppose I have a XSD definition of amount: <xs:element name="Amount" type="amount> And the amounts themselves are given in the following format in the XML: <amount>1.000.00</amount> In other words, the thousand separator and the decimal point are the same. Does this require that the parser... (3 Replies)
Discussion started by: figaro
3 Replies

5. Shell Programming and Scripting

Need to split a xml file in proper format

Hi, I have a file which has xml data but all in single line Ex - <?xml version="1.0"?><User><Name>Robert</Name><Location>California</Location><Occupation>Programmer</Occupation></User> I want to split the data in proper xml format Ex- <?xml version="1.0"?> <User> <Name>Robert</Name>... (6 Replies)
Discussion started by: avishek007
6 Replies

6. Shell Programming and Scripting

XML dateTime format in shell script

How can i frame current date & time in the xml standard dateTime format in shell script 2011-10-18T12:00:00.000000 I got up to the date format using the below code date '+%Y'-'%m'-'%d'T ---------- Post updated at 09:10 AM ---------- Previous update was at 08:53 AM ---------- ... (6 Replies)
Discussion started by: vel4ever
6 Replies

7. Shell Programming and Scripting

From sql Insert Query to XML format

Hi How do I translate Let say Cat inserts.sql gives Insert into PM9_TAXATION_ROUNDING (STATE_GECODE, TAX_TYPE, TAX_AUTHORITY, SYS_CREATION_DATE, SYS_UPDATE_DATE, APPLICATION_ID, DL_SERVICE_CODE, ROUNDING_METHOD) Values ('xx', 'xx', 'x', TO_DATE('10/26/2012 13:01:20',... (3 Replies)
Discussion started by: anuj87in
3 Replies

8. Shell Programming and Scripting

How can I replace data in between xml tags to required format?

Hi All, I have a requirement to change the data in xml file to required format. Below is the scenario. Please find the attached Xml file which contains data that I need to convert.. <ReleaseIndicatorList><ReleaseIndicator>Alternative... (0 Replies)
Discussion started by: Prathyu
0 Replies

9. Shell Programming and Scripting

Convert tag based lines to xml format

Hi All, Can some one help me to convert this line of code to xml format. Thanks in advance, preethy. input: ... (2 Replies)
Discussion started by: preethy
2 Replies
TABS(1) 						    BSD General Commands Manual 						   TABS(1)

NAME
tabs -- set terminal tabs SYNOPSIS
tabs [-n | -a | -a2 | -c | -c2 | -c3 | -f | -p | -s | -u] [+m[n]] [-T type] tabs [-T type] [+[n]] n1[,n2,...] DESCRIPTION
The tabs utility displays a series of characters that clear the hardware terminal tab settings then initialises tab stops at specified posi- tions, and optionally adjusts the margin. In the first synopsis form, the tab stops set depend on the command line options used, and may be one of the predefined formats or at regular intervals. In the second synopsis form, tab stops are set at positions n1, n2, etc. If a position is preceded by a '+', it is relative to the previous position set. No more than 20 positions may be specified. If no tab stops are specified, the ``standard'' UNIX tab width of 8 is used. The options are as follows: -n Set a tab stop every n columns. If n is 0, the tab stops are cleared but no new ones are set. -a Assembler format (columns 1, 10, 16, 36, 72). -a2 Assembler format (columns 1, 10, 16, 40, 72). -c COBOL normal format (columns 1, 8, 12, 16, 20, 55) -c2 COBOL compact format (columns 1, 6, 10, 14, 49) -c3 COBOL compact format (columns 1, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 67). -f FORTRAN format (columns 1, 7, 11, 15, 19, 23). -p PL/1 format (columns 1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61). -s SNOBOL format (columns 1, 10, 55). -u Assembler format (columns 1, 12, 20, 44). +m[n], +[n] Set an n character left margin, or 10 if n is omitted. -T type Output escape sequence for the terminal type type. ENVIRONMENT
The LANG, LC_ALL, LC_CTYPE and TERM environment variables affect the execution of tabs as described in environ(7). The -T option overrides the setting of the TERM environment variable. If neither TERM nor the -T option are present, tabs will fail. EXIT STATUS
The tabs utility exits 0 on success, and >0 if an error occurs. SEE ALSO
expand(1), stty(1), tput(1), unexpand(1), termcap(5) STANDARDS
The tabs utility conforms to IEEE Std 1003.1-2001 (``POSIX.1''). HISTORY
A tabs utility appeared in PWB UNIX. This implementation was introduced in FreeBSD 5.0. BUGS
The current termcap(5) database does not define the 'ML' (set left soft margin) capability for any terminals. BSD
May 20, 2002 BSD
All times are GMT -4. The time now is 02:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy