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.
A couple of hours
Half a Day
A Day
A few Days
A Week
Several Weeks
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
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
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.Originally posted by 999gi
So not over a week then![]()
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
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.gwould take longer to figure out than a simple single level deep file with no attributes.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>
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
Are you running PHP5 yet? if so its very simple.
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
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)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.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
?>
This was the feature that made me upgrade to php5.
Thanks Rich
That looks handy
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
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks