Giter Site home page Giter Site logo

simplecsv's People

Contributors

iklsr avatar shuchkin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

simplecsv's Issues

Deprecated

Hello php 7.49 trigger this errors

Deprecated: Array and string offset access syntax with curly braces is deprecated in ...\shuchkin\simplecsv\src\SimpleCSV.php on line 102

Deprecated: Array and string offset access syntax with curly braces is deprecated in ...\shuchkin\simplecsv\src\SimpleCSV.php on line 103

CSV download functionality

Can you please add download functionality in CSV as you created in XLSX gen?

I have tried to create CSV but for Spanish & Russian languages we are facing issues.

Actual Text : KESCH Számitástechnikai, Kereskedelmi és Szolgál- tató Felelősségü Társaság

After Export in CSV file : KESCH Sz?it?technikai, Kereskedelmi ? Szolg?- tat Felel?ss? T?sas?

How can export cells as Text format

My point is that I want to export excel file as text cells format or any other with empty cells.

Because if it's empty cells and I want to write a number in it, it will be like "123,698,789" but I need like "123698789"

so is there any way to export it.

Wrong delimiter detection under certain conditions

Conditions under which the problem occurs:

  1. The CSV being parsed has the ; delimiter.
  2. The $delimiter parameter is not specified when calling the parse() or import() methods (i.e., it remains 'auto').
  3. The CSV contains a cell with the following character sequence: ", like this:

image
Actual CSV contents:

"cell 1";"cell 2"
"cell 3";"cell ""4"", causing problem"

In these circumstances, the delimiter is auto-detected as ,, although the actual delimiter is ;. This leads to incorrect further CSV parsing, resulting in an array that looks like this:

array (
  0 => 
  array (
    0 => 'cell 1;cell 2',
  ),
  1 => 
  array (
    0 => 'cell 3;cell "4", causing problem',
  ),
)

image
Instead of this:

array (
  0 => 
  array (
    0 => 'cell 1',
    1 => 'cell 2',
  ),
  1 => 
  array (
    0 => 'cell 3',
    1 => 'cell "4" NO problem',
  ),
)

image


As far as I understand, the problem is that the following 'if' condition doesn't cover the case where the file contains $this->_enclosure . ',' (i.e. ", in this case) as an actual cell content (which is escaped as $this->_enclosure . $this->_enclosure . ',' ("", in this case)):

// detect delimiter
if ( strpos($this->_csv, $this->_enclosure . ',' ) !== false ) {
  $this->_delimiter = ',';
} // else ...

So I made a quick fix with an additional check whether the previous character is NOT the same as _enclosure:

// detect delimiter

// quick fix of wrong delimiter detection in some files with doublequotes (`"",` case)
$pos = strpos($this->_csv, $this->_enclosure . ',' );
$prev_char = substr($this->_csv, $pos - 1, 1);

if ( $pos !== false && $prev_char !== $this->_enclosure) {
  $this->_delimiter = ',';
} // else ...

It works for me and solves this one particular case, but it doesn't cover other combinations of enclosures/delimiters inside cells, neither check for some edge cases like empty enclosed cells ("","cell 2"). Please consider implementing the actual fix in your class.

Syntax error in README example

The closing bracket of this array isn't the right kind:
$items = [ ['ISBN', 'title', 'author'], ['618260307','The Hobbit','J. R. R. Tolkien'] );

deprecated warning

Latest php
SimpleCSV::export, strpos
Passing null to parameter #1 ($haystack) of type string is deprecated in SimpleCSV.php on line 162

if (is_null($v)) {continue;}

or something?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.