Last active
January 12, 2019 21:03
-
-
Save vetleledaal/c357f803719a181f8d7de4e810ad909d to your computer and use it in GitHub Desktop.
Creates a csv file containing the article name and main Steam AppID from exports of PCGW.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$fp = fopen('pcgw_steam_ids.csv', 'w'); | |
// For each xml file exported from PCGW ... | |
foreach(glob('*.xml') as $filename) { | |
$file_contents = file_get_contents($filename); | |
// Find every title and steam appid pairs | |
preg_match_all('%<title>([^<]+)<(?:(?!</text>).)+?\|steam appid\s*= *([^\r\n]*)%sm', $file_contents, $results); | |
$count = count($results[1]); | |
for($i=0; $i < $count; $i++) { | |
// Only add valid steam appids to the csv file | |
if(preg_match('%^[1-9]\d*%', $results[2][$i], $match_id) === 1) { | |
fputcsv($fp, [html_entity_decode($results[1][$i], ENT_QUOTES | ENT_HTML5), $match_id[0]]); | |
} | |
} | |
} | |
fclose($fp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment