New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unwanted additional line at end of CSV file #53
Comments
Ok as per the documentation there are several ways to instantiate the object I think you've just combined many of them. The problem may be related to that. I would suggest, simplify your code like below: $filepath = '/path/to/my/csv/file.csv';
$csv = League\Csv\Writer::createFromPath($filepath, 'w');
$csv->insertAll($csv_data); Nothing more... it will work and the empty line should disappear. You do not need to use |
Thanks for your response. I was trying something similar but the missing piece was the "w" in the second argument to create the file. Anyway, it's still putting an empty line at the end of the CSV file. Code is now:
|
The end line is put because of SplFileObject::fputcsv as per documentation:
|
Is it worth doing a PR to have an option which doesn't include the newline? |
No need to PR this, there's a quick workaround for that: function outputWithoutEndingEOL(League\Csv\AbstractCSV $csv)
{
return rtrim($csv->newReader());
} |
I'm trying to create a new CSV file and write it to disk so that it can be emailed. This may not be an issue with the package but may be an issue with the way I am doing things.
Code:
The resulting CSV has all the data in it as expected but there is an additional line with no entry on it.
This is a problem because the resulting CSV has to be uploaded into an Oracle-based system and it does not like empty lines in CSV files.
The text was updated successfully, but these errors were encountered: