Quantcast
Channel: Parsing A Data Feed - Stack Overflow
Browsing latest articles
Browse All 6 View Live

Answer by HenryHayes for Parsing A Data Feed

There is a ready-built PHP parsing library that can auto-detect the CSV format.Example:$reader = new Dfp_Datafeed_File_Reader();$reader->setLocation('test.csv');foreach ($reader AS $record) {...

View Article



Answer by Ryan Abbott for Parsing A Data Feed

You can use explode to get both:$myFile = "File.txt";$fh = fopen($myFile, 'r');$data = fread($fh);fclose($fh);$newLines = explode("\n",$data);foreach($newLines as $s){ $parsed = explode("|",$s);...

View Article

Answer by Zak for Parsing A Data Feed

If you are reading out of your textarea post, you can use the explode function using the newline character as your separator to get each "line" in the variable as a new element of an array, then you...

View Article

Answer by Paul Dixon for Parsing A Data Feed

If the file is small, you can use file() to read it into an array, one line per element.Failing that, read the file in loop using fgets()$handle = fopen("/tmp/inputfile.txt", "r");while...

View Article

Answer by Randy for Parsing A Data Feed

You can read a file into an array of lines and do all the splitting with:$lines = file("filename");foreach($lines as $line) { $parts = explode("|", $line); // do the database inserts here}If you...

View Article


Parsing A Data Feed

I'm not the best at PHP and would be extremely grateful if somebody could help. Basically I need to parse each line of a datafeed and just get each bit of information between each "|" - then I can add...

View Article
Browsing latest articles
Browse All 6 View Live




Latest Images