Skip to content

Instantly share code, notes, and snippets.

@bohwaz
Created February 8, 2017 01:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bohwaz/8501130e1ac28e18edc6191b4f3ff44a to your computer and use it in GitHub Desktop.
Save bohwaz/8501130e1ac28e18edc6191b4f3ff44a to your computer and use it in GitHub Desktop.
Extract Gitlab JSON project list and convert it to CSV
<?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