Skip to content

Instantly share code, notes, and snippets.

@Feiron
Last active January 8, 2019 20:13
Show Gist options
  • Save Feiron/6afa7969cc3380bbace5f66c7330c34a to your computer and use it in GitHub Desktop.
Save Feiron/6afa7969cc3380bbace5f66c7330c34a to your computer and use it in GitHub Desktop.
Bitrix csv work
<?
CModule::IncludeModule('crm');
CModule::IncludeModule('gpw.1cdb');
CModule::IncludeModule('gpw.payments');
require_once($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/csv_data.php");
$csvFile = new CCSVData('R', true);
$csvFile->LoadFile($_SERVER['DOCUMENT_ROOT'] . '/testing/file.csv');
$csvFile->SetDelimiter(';');
$GLOBALS["APPLICATION"]->RestartBuffer();
$strPath = $_SERVER["DOCUMENT_ROOT"] . "/testing/csv_data.csv";
$fp = fopen($strPath, 'w');
while ($arRes = $csvFile->Fetch()) {
for ($i = 0; $i < $arRes[4]; $i++) {
fputcsv($fp, $arRes, ';');
}
}
fclose($fp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment