1

I would like to skip some column to write data in CSV when it generate.

Here is my code to generate CSV in magento.

it would be start writing from column no 20 for first row only then continue with first column.

$csv = new Varien_File_Csv();
    $csvdata = array();
    /* genereate header */
    $csvdata[] = $this->getCsvColumn();

    $path = Mage::getBaseDir() . DS . 'exportmodel';
    if (!is_dir($path)) {
    $ioAdapter = new Varien_Io_File();
    $ioAdapter->mkdir($path, 0775);
     }
    $csv->setLineLength(1000);
    $csv->setDelimiter(';');
    $csv->setEnclosure('"');
    $file = $path . DS . 'importmodel.csv';
    $csv->saveData($file, $csvdata);
4
  • how does $csvdata array look like when you save it? Is it a simple array, a 2-dimational one or more?
    – Marius
    Aug 1, 2017 at 13:01
  • $_columns = array( "Sort order", "Sku", "Title", more title here ); like this Aug 1, 2017 at 13:19
  • not columns. There is not even a columns variable in your code. I asked about csvdata
    – Marius
    Aug 1, 2017 at 13:24
  • it is 2 dimational array mariaus Aug 1, 2017 at 13:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.