View Poll Results: How long should it take

Voters
14. You may not vote on this poll
  • A couple of hours

    9 64.29%
  • Half a Day

    1 7.14%
  • A Day

    3 21.43%
  • A few Days

    0 0%
  • A Week

    0 0%
  • Several Weeks

    1 7.14%
+ Reply to Thread
Results 1 to 12 of 12

 

Thread: How Long Should it take

  1. #1
    aka Antony

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Bristol
    Posts
    966
    Thanks
    0
    Thanked 0 Times in 0 Posts


    Hi

    Just wondered how long people think would be a reasonable amount of time for someone experience in php/xml to come up with a script to convert an xml file to a csv file


    I have a guy doing this for me at the moment and I cant believe how long its taking

  2. #2
    Avoiding real work

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Buckinghamshire
    Posts
    1,373
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If I was doing it for myself then I'd probably knock it up in a couple of hours if it was for a client then I'd probably take half a day so that I could spend a bit of time making sure it was all working OK to save any come back later on.
    Those who can do, those who can't talk about it

  3. #3
    aka Antony

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Bristol
    Posts
    966
    Thanks
    0
    Thanked 0 Times in 0 Posts
    So not over a week then

  4. #4
    Registered User

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Bristol
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by 999gi
    So not over a week then
    NO! There are free php scripts on the net for parsing xml that could be adapted fairly easily to do that, for someone with some experience it shouldn't really take over a day or has already been suggested a few hours.

  5. #5
    Avoiding real work

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Buckinghamshire
    Posts
    1,373
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If it's taken over a week then the guy has either

    a) taken on too much work and is doing the more profitable bits first.
    b) doesn't really have the skills to do the job, but has managed to find one of the scripts that olias mentions and is trying to work out how to adapt it.
    c) hasn't even been able to find a script and has just given up and is hoping you'll give up on him and go away.
    Those who can do, those who can't talk about it

  6. #6
    Registered User

    Status
    Offline
    Join Date
    Aug 2003
    Posts
    2,448
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It would depend a bit on what features are used in the xml file, as you can do a lot of stuff in a xml file that would be hard to convert to a CSV file (the hard bit being how to format the csv rather than making the coding much harder)

    e.g
    Code:
    <Item>
      <ASIN>0091896754</ASIN> 
    - <ItemAttributes>
        <Author>Lucy Young</Author> 
        <Binding>Hardcover</Binding> 
        <Creator Role="Foreword">Mary Berry</Creator> 
        <Height Units="millimeters">252</Height> 
        <Length Units="millimeters">190</Length> 
    - <ListPrice>
        <Amount>1800</Amount> 
        <CurrencyCode>GBP</CurrencyCode> 
        <FormattedPrice>£18.00</FormattedPrice> 
      </ListPrice>
      <NumberOfPages>192</NumberOfPages> 
      <ProductGroup>Book</ProductGroup> 
      <PublicationDate>2004-11-01</PublicationDate> 
      <Publisher>Ebury Press</Publisher> 
      <Title>Secrets From A Country Kitchen</Title> 
      <Weight Units="grams">788</Weight> 
      </ItemAttributes>
    </Item>
    would take longer to figure out than a simple single level deep file with no attributes.

  7. #7
    aka Antony

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Bristol
    Posts
    966
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks guys

    This is a single level file - e.g. a merchant product feed
    I basically have a nice automated system that imports csvs into mysql so I just want a way to easily turn those feeds I can only get as xml into csv so I can use the same system.

    I can download, and use access to convert but I prefer to automate

  8. #8
    Registered User

    Status
    Offline
    Join Date
    Aug 2003
    Posts
    2,448
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Are you running PHP5 yet? if so its very simple.

  9. #9
    aka Antony

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Bristol
    Posts
    966
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Rich

    erm dont think so - 4.something I think

    Its my own server though so I guess I could install it

    Im familiar with php.net is there a function I should search for to read up on

  10. #10
    Registered User

    Status
    Offline
    Join Date
    Aug 2003
    Posts
    2,448
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP 5 adds SimpleXML functions that allow you to treat an xml file as an object.

    So something like the following would be a good start (note, this isn't tested at all)
    PHP Code:
    <?
    $csv
    ='';
    $xml=simplexml_load_file($path-to-xml-file);
    foreach (
    $xml->children() as $item) {
        
    //this will go the first level into the file, which is normally the items
        
    foreach ($item->children() as $property) {
            
    //this will be the next level in, the properties of the item
            
    $csv.='"'.$property.'",';
        }
        
    //finish off the row in the csv file.
        
    $csv.="0\n";
    }
    //save $csv
    ?>
    That assumes the properties in the xml file stay in the same order (they have in all the files I've looked at) and you may need to do a bet more work where the property is added on to the csv to cope with " in the property values, but it should give you a start.

    This was the feature that made me upgrade to php5.

  11. #11
    aka Antony

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Bristol
    Posts
    966
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Rich
    That looks handy

  12. #12
    Registered User

    Status
    Offline
    Join Date
    Sep 2004
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have a script that changes AW XML feeds into mysql. You may be able to adapt that a little.

    http://www.joesharman.co.uk/xml2mysql.zip

    Hope you find it usefull

+ Reply to Thread


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
To Top

Content Relevant URLs by vBSEO 3.5.0 RC2