Don't Get It.

From: Mouse15 Dec 2009 21:16
To: ALL1 of 28
Got this php file, it outputs a tab delimited file with the following headers:

title description
link
image_link
id
price currency
payment_accepted
payment_notes
quantity weight
expiration_date
brand
condition product_type
language

I only want the following headers:

title description
link
image_link
id
price condition

What does I need to change?

</usual disclaimer of me being a complete dafty and request to be patient after the simplistic questions start flowing>
Attachments:
From: Peter (BOUGHTONP)15 Dec 2009 21:33
To: Mouse 2 of 28
I can't be arsed attempting to follow that horrible PHP file, but if the output of it can be trusted to be consistent, the quick and dirty solution is to do this:

PHP code:
$MyFile = fopen('myfile.tsv','r');
$MyText = fread($MyFile,filesize($MyFile));
fclose($MyFile);
 
$MyText = preg_replace
	( '/^((?:[^\t]+\t){6})(?:[^\t]+\t){7}([^\t]+).*$/mig'
	, '$1$2'
	, $MyText
	);
 
$MyNewFile = fopen('mynewfile.tsv','w');
$MyText = fwrite($MyNewFile,$MyText);
fclose($MyNewFile);


It's not going to be the most efficient method, but it might be good enough.

If you want a better solution, you'll have to wait for someone that doesn't find that PHP script incredibly painful to look at. :(
EDITED: 15 Dec 2009 21:37 by BOUGHTONP
From: Mouse15 Dec 2009 21:39
To: Peter (BOUGHTONP) 3 of 28
Yeah, it's not mine, glad it's not just me then.
From: Mouse15 Dec 2009 21:47
To: Peter (BOUGHTONP) 4 of 28
Also, I appreciate you typing all that, but it doesn't mean much to me.. Would that replace all or that PHP file I attached or just part of it?
EDITED: 15 Dec 2009 21:49 by MOUSE
From: Peter (BOUGHTONP)15 Dec 2009 21:50
To: Mouse 5 of 28
Shove it on the end.

The end of what, I'm not quite sure. :$

Are you browsing directly to the attached file, or using include(file.php) or similar?
From: Mouse15 Dec 2009 21:53
To: Peter (BOUGHTONP) 6 of 28
That file can be found in the module/froogle/ directory. I started messing with it after reading this.
From: Peter (BOUGHTONP)15 Dec 2009 23:13
To: Mouse 7 of 28

I got confused with that link, so I jumped into PHPEclipse and fixed the file.

 

Not quite so bad to identify the relevant parts to change with a decent font, word wrap off, and syntax formatting on, but I've still only modified the actual file output stuff - that utterly evil SQL query is no doubt doing more work than it needs to be, but I'm definitely not diving in to go fix that.

 

Anyway, should be attached. (Use BeyondCompare/WinDiff/etc if you want to see what I changed).

EDITED: 15 Dec 2009 23:13 by BOUGHTONP
Attachments:
From: Mouse15 Dec 2009 23:23
To: Peter (BOUGHTONP) 8 of 28
Cheers Pete, I'll look over that with a furrowed brow. Just tried using it as is and it broke, but I'll look at it closer tomorrow.
From: Peter (BOUGHTONP)15 Dec 2009 23:39
To: Mouse 9 of 28
Bah!

Broke with an error broke, or worked but produced the wrong results broke?

And did the original version work (just with too many columns) or had you not tried it?
From: Mouse15 Dec 2009 23:54
To: Peter (BOUGHTONP) 10 of 28

Well, there's a section in my admin to export a Tab Delimited file, that just doesn't work.

 

The original works but gives me more columns than I require.

From: Peter (BOUGHTONP)16 Dec 2009 00:05
To: Mouse 11 of 28
Arse.

I missed the trailing concatenation and semi-colon stuff. (I blame PHP being crap for that.)

Anyway, this one will work.
Attachments:
From: Mouse16 Dec 2009 00:22
To: Peter (BOUGHTONP) 12 of 28
Cheers Pete, will try that tomorrow when I am on a desktop, for it is fiddlier than Vannesa Mae on the Netbook.
From: CHYRON (DSMITHHFX)16 Dec 2009 01:01
To: Peter (BOUGHTONP) 13 of 28

Have you tried PDT yet? If so, Howse it compare to PHPEclipse?

 


deit: mind you, this is like me axing a brain surgeon if he prefers a hacksaw or a chainsaw...

EDITED: 16 Dec 2009 01:06 by DSMITHHFX
From: Peter (BOUGHTONP)16 Dec 2009 01:17
To: CHYRON (DSMITHHFX) 14 of 28
Haven't tried it - was about three years ago when I setup that Eclipse config, and at the time PHPEclipse was the only (usable) Eclipse plugin for PHP.

Since I do so little PHP stuff, I haven't bothered updating, nevermind considering alternatives.
From: CHYRON (DSMITHHFX)16 Dec 2009 01:32
To: Peter (BOUGHTONP) 15 of 28
The only reason I ask is because Aptana ('nuther Eclipse-based ide, which I happen to use rather a lot) recently switched to PDT.
From: Peter (BOUGHTONP)16 Dec 2009 01:43
To: CHYRON (DSMITHHFX) 16 of 28
Aptana sucks.

Tried it a couple of times (for JS/CSS/XML stuff), most recently about a month ago, but every time it has annoyed me a great deal.

My work colleagues feel the same, and they're far less fussy about their software than I am.
From: CHYRON (DSMITHHFX)16 Dec 2009 02:01
To: Peter (BOUGHTONP) 17 of 28
Yeah but it sucks less than netbeans ime (at least for generic [x]html/css, and beats the living shit outta anyfink for rails, dunno 'bout javascript per se or anyting heavy), and is a pretty decent replacement for dw, in that it doesn't attempt to 'help' you rewrite your code into an undifferentiated mass of blood, bone and brainmatter...
From: Mouse16 Dec 2009 11:23
To: Peter (BOUGHTONP) 18 of 28
Still giving me the same old headers that when I export a file :(
From: Peter (BOUGHTONP)16 Dec 2009 11:54
To: Mouse 19 of 28
Huh? :S

Look at lines 115..122 - the old headers should be commented out with double slash, with the shortened versions beneath?

Only thing I can think is that maybe I've gone mad and PHP doesn't use that for comments - try switching for the hash that the other comments use and see if that makes a difference?
From: Mouse16 Dec 2009 12:29
To: Peter (BOUGHTONP) 20 of 28
It says:
code:
if ($fp !== false) {
		# Write file header
 
		# Full header: 
		# title\tdescription\tlink\timage_link\tid\texpiration_date\tlabel\tprice\tprice_type\tcurrency\tpayment_accepted\tpayment_notes\tquantity\tbrand\tupc\tisbn\tmemory\tprocessor_speed\tmodel_number\tsize\tweight\tcondition\tcolor\tactor\tartist\tauthor\tformat\tproduct_type\tlocation
		if ($froogle_iso) {
			// fputs($fp, "title\tdescription\tlink\timage_link\tid\tprice\tcurrency\tpayment_accepted\tpayment_notes\tquantity\tweight\texpiration_date\tbrand\tcondition\tproduct_type\tlanguage\n");
			fputs($fp, "title\tdescription\tlink\timage_link\tid\tprice\tcondition\tlanguage\n");
 
		} else {
			// fputs($fp, "title\tdescription\tlink\timage_link\tid\tprice\tcurrency\tpayment_accepted\tpayment_notes\tquantity\tweight\texpiration_date\tbrand\tcondition\tproduct_type\n");
			fputs($fp, "title\tdescription\tlink\timage_link\tid\tprice\tcondition\n");
		}


I believe it is commented out correctly... I kind of did that sort of thing myself before and it didn't work, so I assumed there must be something else.

Sorry Pete :(