Skip to content

Instantly share code, notes, and snippets.

@opensussex
Last active January 13, 2017 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save opensussex/079f727f4b918c50c6e4e656f5a07dc6 to your computer and use it in GitHub Desktop.
Save opensussex/079f727f4b918c50c6e4e656f5a07dc6 to your computer and use it in GitHub Desktop.
<?php
$yodiz_columns = [
[
'title'=>'Position',
'from_done_done' =>2
],
[
'title'=>'Id',
'from_done_done'=>2,
'append'=> 'BG-',
],
[
'title'=>'Title',
'from_done_done'=>3
],
[
'title'=>'Type',
'from_done_done'=>null,
'default'=> 'issue'
],
[
'title'=>'DescriptionPlainText',
'from_done_done'=>4
],
[
'title'=>'Points',
'from_done_done'=>null
],
[
'title'=>'Effort Estimated',
'from_done_done'=>null,
'default'=>'0'
],
[
'title'=>'Effort Remaining',
'from_done_done'=>null,
'default'=>'0'
],
[
'title'=>'Effort Spent',
'from_done_done'=>null,
'default'=>'0'
],
[
'title'=>'Status',
'from_done_done'=>null,
'default'=>'New'
],
[
'title'=>'Created by',
'from_done_done'=>7
],
[
'title'=>'Created on',
'from_done_done'=>14
],
[
'title'=>'Responsible',
'from_done_done'=>null
],
[
'title'=>'Sprint',
'from_done_done'=>null
],
[
'title'=>'Release',
'from_done_done'=>null
],
[
'title'=>'Component',
'from_done_done'=>null
],
[
'title'=>'Due Date',
'from_done_done'=>null
],
[
'title'=>'Priority',
'from_done_done'=>6
],
[
'title'=>'Severity',
'from_done_done'=>null,
'default'=>'Normal'
],
[
'title'=>'Issue Priority',
'from_done_done'=>null,
'default'=>'FALSE'
],
[
'title'=>'Followers',
'from_done_done'=>null
],
[
'title'=>'Other Responsibles',
'from_done_done'=>null
],
[
'title'=>'Tags',
'from_done_done'=>16
],
[
'title'=>'Steps To Reproduce',
'from_done_done'=>null
],
[
'title'=>'User Story Id',
'from_done_done'=>null
],
[
'title'=>'User Story Title',
'from_done_done'=>null
]
];
/*
$done_done_columns = [
'0'=>'URL',
'1'=>'Project',
'2'=>'Issue#',
'3'=>'Title',
'4'=>'Description',
'5'=>'Status',
'6'=>'Priority',
'6'=>'CreatorName',
'8'=>'CreatorEmail',
'9'=>'FixerName',
'10'=>'FixerEmail',
'11'=>'TesterName',
'12'=>'TesterEmail',
'13'=>'LastUpdatedDate',
'14'=>'CreatedDate',
'15'=>'DueDate',
'16'=>'Tags'
];
*/
$row = 1;
$export = [];
if (($handle = fopen("DoneDone__AppMaintenance_issues.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 0, ",")) !== FALSE) {
$num = count($data);
echo "PROCESSING:- $num fields in line $row: \n";
$value_row = [];
if($row == 1) {
foreach($yodiz_columns as $yodiz_column) {
//var_dump($yodiz_column);
$value_row[] = $yodiz_column['title'];
}
}else{
if($num <= 17) {
//for ($c=0; $c < $num; $c++) {
foreach($yodiz_columns as $yodiz_column) {
//var_dump($yodiz_column);
if($yodiz_column['from_done_done']) {
$new_val = $data[$yodiz_column['from_done_done']];
if(isset($yodiz_column['append'])) {
$new_val = $yodiz_column['append'] . $data[$yodiz_column['from_done_done']];
}
$value_row[] = $new_val;
} else if (isset($yodiz_column['default'])){
$value_row[] = $yodiz_column['default'];
}else {
$value_row[] = '';
}
}
"\n";
//}
}
}
$row++;
$export[] = $value_row;
}
fclose($handle);
$fp = fopen(md5(time()).'.csv', 'w');
foreach($export 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