Skip to content
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

Added auto_detect_line_endings #16

Closed
wants to merge 2 commits into from
Closed

Conversation

jackfruh
Copy link
Contributor

@jackfruh jackfruh commented Sep 6, 2015

Added auto_detect_line_endings.
This fixed a compatibility problem with CSV files generated in Excel Mac (excel mac used x0D for line endings instead of x0A)
Note that set_ini is temporary for that request. it does not change the users php.ini http://php.net/manual/en/filesystem.configuration.php#ini.auto-detect-line-endings
http://php.net/manual/en/function.ini-set.php

Added auto detect line endings.
http://php.net/manual/en/filesystem.configuration.php#ini.auto-detect-li
ne-endings
This resolved a problem importing csv files exported from Excel Mac
(which had line endings of x0A instead of x0D)
ini_set applies to the current request only. it is not making any
permanent changes in anyones php.ini.
@Flynsarmy
Copy link
Owner

Rather then setting and then leaving it that way, please save the current INI setting to a variable, set auto_detect_line_endings to true, do the * seedFromCSV_, then set *auto_detect_line_endings_ back to its original value after the read.

We don't want users INI settings changed in our package or it could result in unpredictable behaviour for the end user later in their scripts execution.

@jackfruh
Copy link
Contributor Author

jackfruh commented Sep 6, 2015

Makes sense.
I've added some code on my end but want to test before commiting up - hopefully later tonight.
$lineendings = ini_get("auto_detect_line_endings");
ini_set("auto_detect_line_endings", true);
$this->seedFromCSV($this->filename, $this->csv_delimiter);
ini_set("auto_detect_line_endings", $lineendings);

@Flynsarmy Flynsarmy closed this Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants