Created
February 8, 2017 01:23
-
-
Save bohwaz/8501130e1ac28e18edc6191b4f3ff44a to your computer and use it in GitHub Desktop.
Extract Gitlab JSON project list and convert it to CSV
This file contains hidden or 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 | |
$projects = []; | |
$projects[] = [ | |
'Project path', | |
'Owner', | |
'Name', | |
'Description', | |
'Created', | |
'Last activity', | |
'URL', | |
]; | |
foreach (glob('*.json') as $file) | |
{ | |
$file = json_decode(file_get_contents($file)); | |
foreach ($file as $row) | |
{ | |
$projects[] = [ | |
$row->path_with_namespace, | |
$row->namespace->path, | |
$row->name, | |
$row->description, | |
$row->created_at, | |
$row->last_activity_at, | |
$row->web_url, | |
]; | |
} | |
} | |
$fp = fopen('php://stdout', 'w'); | |
foreach ($projects as $row) | |
{ | |
fputcsv($fp, $row); | |
} | |
fclose($fp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment