Create the csv string rappresenting the CsvFile

@return  String $csv
@throws  NoDataException
349929
public function getCsvString($separator, CsvFile $csv_file = null)
	{
		$csv_file = $csv_file ? $csv_file : $this->csv_file;
		$csv = '';
		if( ! isset($csv_file) )
		{
			throw new NoDataException;
		}
		else
		{
			foreach($csv_file as $key => $csv_line)
			{
				if($key == 0)
				{
					$csv.=$csv_line->getCsvHeader($separator);
				}
				$csv.=$csv_line->getCsvString($separator);
			}
		}

		return $csv;
	}
844620
final public function startGetItemsCsv()
    {
        $this->buffer->setFile($this->config->getItemsCsvPath());
        $this->createItemsCsv();
        $this->buffer->finish();
    }
1194585
protected function buildCols()
    {
        if (!$this->cols) {
            throw new Exception('No columns in the SELECT.');
        }

        $cols = array();
        foreach ($this->cols as $key => $val) {
            if (is_int($key)) {
                $cols[] = $this->quoteNamesIn($val);
            } else {
                $cols[] = $this->quoteNamesIn("$val AS $key");
            }
        }

        return $this->indentCsv($cols);
    }
1325708
public function toString()
    {
        $result = '';
        foreach ($this->getChunkCursor() as $chunk) {
            $result .= $chunk['data']->getData();
        }
        return $result;
    }
189643
public String csvHeader() {

        if (m_csvItemFormatter != null) {
            return m_csvItemFormatter.csvHeader();
        } else {
            StringBuffer csv = new StringBuffer(1024);
            Iterator<CmsListColumnDefinition> itCols = m_columns.elementList().iterator();
            while (itCols.hasNext()) {
                CmsListColumnDefinition col = itCols.next();
                if (!col.isVisible()) {
                    continue;
                }
                csv.append(col.csvHeader());
                csv.append("\t");
            }
            csv.append("\n\n");
            return csv.toString();
        }
    }
412380
public function csv() {
        global $wpdb;

        $fd = fopen('php://temp/maxmemory:1048576', 'w');
        fputcsv($fd, ["date", "channel", "level", "message", "context"]);

        $rows = $wpdb->get_results("select date, channel, level, message, context from {$this->table} order by id asc", ARRAY_N);

        if (is_array($rows) && count($rows) > 0) {
            foreach($rows as $row) {
                fputcsv($fd, $row);
            }
        }

        rewind($fd);
        $csv = stream_get_contents($fd);
        fclose($fd);

        return $csv;
    }
1214544
public function appendCsv($data)
    {
        $counter    = 0;
        $rows       = str_getcsv($data, $this->_csvLineDelimiter);

        foreach ($rows as $row) {
            $rowData = str_getcsv(
                $row,
                $this->_csvDelimiter,
                $this->_csvEnclosure,
                $this->_csvEscape
            );

            $this->_putData($this->_integerKeyPrefix . $counter, $rowData);

            $counter++;
        }

        if ($this->_objectCreation) {
            return $this->_afterAppendDataToNewObject();
        }

        return $this;
    }
1102499
protected function resolveCsvHeader()
    {
        $header = [];

        if (!$this->isEmpty()) {
            $single = $this->first();
            $header = array_keys(Arr::dot($single));
        }

        return $header;
    }
379370
public function createStrRepresentation()
    {
        $entity = $this->getEntityData();
        if (is_array($entity) || $entity instanceof \ArrayAccess) {
            // for some reason, implode does not work directly on the entity traversable
            $strArr = array();
            foreach ($entity as $e) {
                $strArr[] = $e->__toString();
            }
            return implode("\x1E", $strArr); // ASCII "record separator" character
        } elseif ($entity) {
            return $entity->__toString();
        } else {
            return '';
        }
    }
1176122
public String generateCsv() throws ClassNotFoundException {

        CmsHtmlList list = A_CmsListDialog.getListObject(Class.forName(getParamListclass()), getSettings());
        return list.listCsv();
    }
901132
def make_csv(data):
    
    # Convert sub-dicts to news cols
    for entry in data:
        rval = entry
        if isinstance(data, dict):
            rval = data[entry]
        todel = []
        toadd = {}
        for key, val in rval.items():
            if isinstance(val, dict):
                for key2, val2 in val.items():
                    toadd[str(key) + "[" + str(key2) + "]"] = val2
                todel.append(key)
        for k in todel:
            del rval[k]
        for k, v in toadd.items():
            rval[k] = v

    # Convert everything to CSV
    columns = set()
    output = [[]]
    if isinstance(data, dict):
        output[0].append("id")
        for entry in data:
            for col in data[entry]:
                columns.add(col)
    else:
        for entry in data:
            for col in entry:
                columns.add(col)

    columns = sorted(columns)

    for col in columns:
        output[0].append(col)

    if isinstance(data, dict):
        for entry in data:
            new_output = [str(entry)]
            for col in columns:
                new_output.append(str(data[entry][col]) if col in data[entry] else "")
            output.append(new_output)
    else:
        for entry in data:
            new_output = []
            for col in columns:
                new_output.append(str(entry[col]) if col in entry else "")
            output.append(new_output)

    csv_string = io.StringIO()
    csv_writer = UnicodeWriter(csv_string)
    for row in output:
        csv_writer.writerow(row)
    csv_string.seek(0)
    web.header('Content-Type', 'text/csv; charset=utf-8')
    web.header('Content-disposition', 'attachment; filename=export.csv')
    return csv_string.read()
563831
public function toCsv($data = null, $delimiter = null)
	{
		// csv format settings
		$newline = Arr::get($this->config, 'csv.newline', "\n");
		$delimiter or $delimiter = Arr::get($this->config, 'csv.delimiter', ',');
		$enclosure = Arr::get($this->config, 'csv.enclosure', '"');
		$escape = Arr::get($this->config, 'csv.escape', '\\');

		// escape function
		$escaper = function($items) use($enclosure, $escape) {
			return array_map(function($item) use($enclosure, $escape){
				return str_replace($enclosure, $escape.$enclosure, $item);
			}, $items);
		};

		if ($data === null)
		{
			$data = $this->data;
		}

		if (is_object($data) and ! $data instanceof \Iterator)
		{
			$data = $this->toArray($data);
		}

		// Multi-dimensional array
		if (is_array($data) and Arr::isMulti($data))
		{
			$data = array_values($data);

			if (Arr::isAssoc($data[0]))
			{
				$headings = array_keys($data[0]);
			}
			else
			{
				$headings = array_shift($data);
			}
		}
		// Single array
		else
		{
			$headings = array_keys((array) $data);
			$data = array($data);
		}

		$output = $enclosure.implode($enclosure.$delimiter.$enclosure, $escaper($headings)).$enclosure.$newline;

		foreach ($data as $row)
		{
			$output .= $enclosure.implode($enclosure.$delimiter.$enclosure, $escaper((array) $row)).$enclosure.$newline;
		}

		return rtrim($output, $newline);
	}
18392
public function write()
	{
		$lines		= array();
		$sections	= $this->getSections();
		foreach( $sections as $section )
		{
			$lines[]	= "[".$section."]";
			foreach( $this->data[$section] as $key => $value )
				$lines[]	= $this->fillUp( $key )."=".$value;
		}
		return FS_File_Writer::saveArray( $this->fileName, $lines );
		$this->read();
	}
1262828
protected function makeCsvFileTitle()
    {
        return vsprintf('%s %s as of %s at %s.csv', [
            Decoy::site(),
            $this->title(),
            Carbon::now()->format('n.j.y'),
            Carbon::now()->format('g:i A'),
        ]);
    }
1317521
public function toCSV()
    {
        // create a temporary file so we can write the CSV out
        $writer = Writer::createFromFileObject(new SplTempFileObject);

        // add the header line
        $writer->insertOne($this->getHeaders());

        // go through each record
        foreach ($this->results as $r) {
            $record = [];

            // go through each field and ensure that each record is prepared in an order consistent with the headers
            foreach ($this->getHeaders() as $h) {
                $record[] = $r->get($h);
            }
            $writer->insertOne($record);
        }

        // return as a string
        return (string) $writer;
    }
758305
protected function buildFrom()
    {
        if (!$this->from) {
            return '';
        }

        $refs = array();
        foreach ($this->from as $from) {
            $refs[] = implode(' ', $from);
        }
        return ' FROM' . $this->indentCsv($refs);
    }
325929
public function toJson ()
    {
        $rows    = array_map("str_getcsv", explode("\n", trim($this->data)));
        $columns = array_shift($rows);
        $csv     = array();

        foreach ($rows as $row)
        {
            $csv[] = array_combine($columns, $row);
        }

        return json_encode($csv);
    }