We help IT Professionals succeed at work.
Get Started

Help with a Python script converting xml to csv

Scott Abraham
on
742 Views
Last Modified: 2018-12-14
I have an xml file that I want to extract data from and put it into a CSV file.  I have most the script working fine.  My problem is each row or data point needs a time stamp.  In the xml the times are given as a start and stop time with the number of time intervals/data points given instead of time.

For Instance:
<ContiguousIntervalSet NumberOfReadings="24">
          <TimePeriod StartTime="2017-03-21T00:00:00-05:00" EndTime="2017-03-22T00:00:00-05:00" />

Open in new window

This tells me that their are 24 reads over 24 hours, each one being at the top of the hour.
Here is what the reads look like:
 <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />

Open in new window

This tells me the 24 data points for the time frame, but no date/time.

This tells me what item and point I am looking for:
<ChannelID ServicePointChannelID="73825602:101" />

Open in new window

Ideally in the output file in this instance it would be like this:
Value,EntityId,ReadingTime,ServicePointChannelID
1,73825602,2017-03-21T00:00:00-05:00,101
1,73825602,2017-03-21T01:00:00-05:00,101
1,73825602,2017-03-21T02:00:00-05:00,101
1,73825602,2017-03-21T03:00:00-05:00,101
1,73825602,2017-03-21T04:00:00-05:00,101
1,73825602,2017-03-21T05:00:00-05:00,101
1,73825602,2017-03-21T06:00:00-05:00,101
1,73825602,2017-03-21T07:00:00-05:00,101
1,73825602,2017-03-21T08:00:00-05:00,101
1,73825602,2017-03-21T09:00:00-05:00,101
1,73825602,2017-03-21T10:00:00-05:00,101
1,73825602,2017-03-21T11:00:00-05:00,101
1,73825602,2017-03-21T12:00:00-05:00,101
1,73825602,2017-03-21T13:00:00-05:00,101
1,73825602,2017-03-21T14:00:00-05:00,101
1,73825602,2017-03-21T15:00:00-05:00,101
1,73825602,2017-03-21T16:00:00-05:00,101
1,73825602,2017-03-21T17:00:00-05:00,101
1,73825602,2017-03-21T18:00:00-05:00,101
1,73825602,2017-03-21T19:00:00-05:00,101
1,73825602,2017-03-21T20:00:00-05:00,101
1,73825602,2017-03-21T21:00:00-05:00,101
1,73825602,2017-03-21T22:00:00-05:00,101
1,73825602,2017-03-21T23:00:00-05:00,101

Open in new window

I can get it to output:
Value,EntityId,ServicePointChannelID
1.0,73825602,101
1.0,73825602,101
1.0,73825602,101
1.0,73825602,101
1.0,73825602,101
1.0,73825602,101
1.0,73825602,101
1.0,73825602,101
1.0,73825602,101
1.0,73825602,101
1.0,73825602,101
1.0,73825602,101
1.0,73825602,101
1.0,73825602,101
1.0,73825602,101
1.0,73825602,101
1.0,73825602,101

Open in new window

Here is a sample of the XML file with two time periods:
<?xml version="1.0" encoding="us-ascii" standalone="yes"?>
<MeterReadingDocument xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ReadingStatusRefTable>
    <ReadingStatusRef Ref="1">
      <UnencodedStatus SourceValidation="NV">
        <StatusCodes>
          <Code>ESTIMATED</Code>
          <Code>ESTNUMREPLACE</Code>
          <Code>ESTUNSCALED</Code>
          <Code>GAP</Code>
          <Code>NV</Code>
          <Code>VEESET1PV</Code>
          <Code>VEESET2NV</Code>
          <Code>VEESET3NV</Code>
        </StatusCodes>
      </UnencodedStatus>
    </ReadingStatusRef>
	<!--DELETED LARGE AMOUNT OF ReadingStatusRef inumerations -->
  </ReadingStatusRefTable>
  <Header>
    <IEE_System Id="REDACTED" />
    <Creation_Datetime Datetime="2017-03-22T09:09:21Z" />
    <Timezone Id="UTC" />
    <Path FilePath="REDACTED" />
    <Export_Template Id="REDACTED" />
    <CorrelationID Id="" />
  </Header>
  <ImportExportParameters CreateResubmitFile="false" CreateReadingGroupForRegisterReads="true">
    <DataFormat ReadingTimestampType="MeterDefault" DSTTransitionType="REDACTED" />
  </ImportExportParameters>
  <Channels>
    <Channel StartDate="2017-03-21T00:00:00-05:00" EndDate="2017-03-22T00:00:00-05:00" TimeZone="CentralUS" IsRegister="false" MarketType="Electric" IntervalLength="60" NumberOfDials="-1" PulseMultiplier="1" PressureCompensationFactor="1" IsReadingDecoded="true" ReadingsInPulse="false">
      <ChannelID ServicePointChannelID="73825602:101" />
      <ContiguousIntervalSets>
        <ContiguousIntervalSet NumberOfReadings="24">
          <TimePeriod StartTime="2017-03-21T00:00:00-05:00" EndTime="2017-03-22T00:00:00-05:00" />
          <Readings>
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
            <Reading Value="1.0" StatusRef="1" />
          </Readings>
          <ExportRequest RequestID="702" EntityType="ServicePoint" EntityID="73825602" RequestSource="Scheduled" />
        </ContiguousIntervalSet>
      </ContiguousIntervalSets>
    </Channel>
	<Channel StartDate="2017-03-21T00:00:00-05:00" EndDate="2017-03-22T00:00:00-05:00" TimeZone="CentralUS" IsRegister="false" MarketType="Electric" IntervalLength="5" NumberOfDials="-1" PulseMultiplier="0.025" PressureCompensationFactor="1" IsReadingDecoded="true" ReadingsInPulse="false">
      <ChannelID ServicePointChannelID="76058806:404" />
      <ContiguousIntervalSets>
        <ContiguousIntervalSet NumberOfReadings="288">
          <TimePeriod StartTime="2017-03-21T00:00:00-05:00" EndTime="2017-03-22T00:00:00-05:00" />
          <Readings>
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
            <Reading Value="0.0" StatusRef="3" />
          </Readings>
          <ExportRequest RequestID="702" EntityType="ServicePoint" EntityID="76058806" RequestSource="Scheduled" />
        </ContiguousIntervalSet>
      </ContiguousIntervalSets>
    </Channel>
</Channels>
</MeterReadingDocument>

Open in new window

Here is my py code:
import xml.etree.ElementTree as ET
import csv

tree = ET.parse('dataexport.xml')
root = tree.getroot()[3]

with open('dataexport.csv', 'wb') as fout:
    writer = csv.writer(fout)
    row = ['Value', 'EntityId', 'ServicePointChannelID']
    writer.writerow(row)
    for channel in tree.iter('Channel'):
        for exportrequest in channel.iter('ExportRequest'):
            entityid = exportrequest.attrib.get('EntityID')
        for channelid in channel.iter ('ChannelID'):
            servicepointchannelid = channelid.attrib.get ('ServicePointChannelID')
            for meterread in channel.iter('Reading'):
                read = meterread.attrib.get('Value')
                row = [read, entityid, servicepointchannelid[9:]]
                print ', '.join(row)
                writer.writerow(row)

Open in new window

I am vexed.  Any help would be appreciated!
Comment
Watch Question
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE