CodingDon't Get It.

 

Press Ctrl+Enter to quickly submit your post
Quick Reply  
 
 
  
 From:  Mouse  
 To:  ALL
36956.1 
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>

Which of the following would you most prefer?
A: a flower,
B: a pretty puppy from your sweety, or
C: a large properly formatted data file?

Attachments:
froogle-orig.php

0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  Mouse     
36956.2 In reply to 36956.1 
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. :(
0/0
 Reply   Quote More 

 From:  Mouse  
 To:  Peter (BOUGHTONP)     
36956.3 In reply to 36956.2 
Yeah, it's not mine, glad it's not just me then.

Which of the following would you most prefer?
A: a flower,
B: a pretty puppy from your sweety, or
C: a large properly formatted data file?
0/0
 Reply   Quote More 

 From:  Mouse  
 To:  Peter (BOUGHTONP)     
36956.4 In reply to 36956.2 
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?

Which of the following would you most prefer?
A: a flower,
B: a pretty puppy from your sweety, or
C: a large properly formatted data file?
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  Mouse     
36956.5 In reply to 36956.4 
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?
0/0
 Reply   Quote More 

 From:  Mouse  
 To:  Peter (BOUGHTONP)     
36956.6 In reply to 36956.5 
That file can be found in the module/froogle/ directory. I started messing with it after reading this.

Which of the following would you most prefer?
A: a flower,
B: a pretty puppy from your sweety, or
C: a large properly formatted data file?
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  Mouse     
36956.7 In reply to 36956.6 

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).

Attachments:
new-froogle.php

0/0
 Reply   Quote More 

 From:  Mouse  
 To:  Peter (BOUGHTONP)     
36956.8 In reply to 36956.7 
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.

Which of the following would you most prefer?
A: a flower,
B: a pretty puppy from your sweety, or
C: a large properly formatted data file?
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  Mouse     
36956.9 In reply to 36956.8 
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?
0/0
 Reply   Quote More 

 From:  Mouse  
 To:  Peter (BOUGHTONP)     
36956.10 In reply to 36956.9 

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.


Which of the following would you most prefer?
A: a flower,
B: a pretty puppy from your sweety, or
C: a large properly formatted data file?
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  Mouse     
36956.11 In reply to 36956.10 
Arse.

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

Anyway, this one will work.

Attachments:
new-froogle.php

0/0
 Reply   Quote More 

 From:  Mouse  
 To:  Peter (BOUGHTONP)     
36956.12 In reply to 36956.11 
Cheers Pete, will try that tomorrow when I am on a desktop, for it is fiddlier than Vannesa Mae on the Netbook.

Which of the following would you most prefer?
A: a flower,
B: a pretty puppy from your sweety, or
C: a large properly formatted data file?
0/0
 Reply   Quote More 

 From:  CHYRON (DSMITHHFX)  
 To:  Peter (BOUGHTONP)     
36956.13 In reply to 36956.7 

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...


----
"Listen to 11,000 stations..."
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  CHYRON (DSMITHHFX)     
36956.14 In reply to 36956.13 
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.
0/0
 Reply   Quote More 

 From:  CHYRON (DSMITHHFX)  
 To:  Peter (BOUGHTONP)     
36956.15 In reply to 36956.14 
The only reason I ask is because Aptana ('nuther Eclipse-based ide, which I happen to use rather a lot) recently switched to PDT.

----
"Listen to 11,000 stations..."
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  CHYRON (DSMITHHFX)     
36956.16 In reply to 36956.15 
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.
0/0
 Reply   Quote More 

 From:  CHYRON (DSMITHHFX)  
 To:  Peter (BOUGHTONP)     
36956.17 In reply to 36956.16 
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...

----
"Listen to 11,000 stations..."
0/0
 Reply   Quote More 

 From:  Mouse  
 To:  Peter (BOUGHTONP)     
36956.18 In reply to 36956.11 
Still giving me the same old headers that when I export a file :(

Which of the following would you most prefer?
A: a flower,
B: a pretty puppy from your sweety, or
C: a large properly formatted data file?
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  Mouse     
36956.19 In reply to 36956.18 
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?
0/0
 Reply   Quote More 

 From:  Mouse  
 To:  Peter (BOUGHTONP)     
36956.20 In reply to 36956.19 
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 :(

Which of the following would you most prefer?
A: a flower,
B: a pretty puppy from your sweety, or
C: a large properly formatted data file?
0/0
 Reply   Quote More 

Reply to All  
 

1–20  21–28

Rate my interest:

Adjust text size : Smaller 10 Larger

Beehive Forum 1.5.2 |  FAQ |  Docs |  Support |  Donate! ©2002 - 2024 Project Beehive Forum

Forum Stats