Coder Social home page Coder Social logo

json-csv's People

Contributors

andreybolonin avatar hopeseekr avatar intelliapps avatar loekvangool avatar martinsustek avatar ozdemirburak avatar theadeyemiolayinka 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

Watchers

 avatar  avatar

json-csv's Issues

Delimiter

Hi!
I would like to know if there's a way to set the delimiter to ; (Excel csv).
When I set 'delimiter' => ';', instead of 'delimiter' => ',', in Csv.php, I get false output.
Is there a solution to this?

Edit: In some Windows localizations, a comma is used for the currency decimal, so Windows sets the list separator to ;.

Cheers!

Test JSON to CSV Conversion

The library is functional and has performed as expected during initial testing with a set of predefined test cases. However, to ensure its robustness, accuracy, and readiness for a broader release, it's essential to subject it to testing with a diverse range of JSON files.

  • Convert a variety of JSON files to CSV using this library.
  • Use a mix of simple, complex, nested, large, and small JSON files.
  • Ensure the testing covers different data types such as strings, numbers, booleans, nulls, arrays, and objects.

This testing will aid in identifying any hidden bugs, edge cases, or performance issues that might not have surfaced during initial testing.

If you find any bugs, feel free to fix them.

Version to check: 0.5.0-alpha

Note: There's no need to ask for assignment, just proceed with testing. Also, feel free to add new tests to the tests folder.

Value as index?

In CSV to JSON, would there be a way to set one of the columns as the object index, instead of having the output json indexed by number? Ie. the example from the readme:

[
  {
    "SepalLength": "5.1",
    "SepalWidth": "3.5",
    "PetalLength": "1.4",
    "PetalWidth": "0.2",
    "Name": "Iris-setosa"
  },
  {
    "SepalLength": "7.0",
    "SepalWidth": "3.2",
    "PetalLength": "4.7",
    "PetalWidth": "1.4",
    "Name": "Iris-versicolor"
  },
  {
    "SepalLength": "6.3",
    "SepalWidth": "3.3",
    "PetalLength": "6.0",
    "PetalWidth": "2.5",
    "Name": "Iris-virginica"
  }
]

to

[
 "Iris-setosa":  {
    "SepalLength": "5.1",
    "SepalWidth": "3.5",
    "PetalLength": "1.4",
    "PetalWidth": "0.2",
    "Name": "Iris-setosa"
  },
 "Iris-versicolor":  {
    "SepalLength": "7.0",
    "SepalWidth": "3.2",
    "PetalLength": "4.7",
    "PetalWidth": "1.4",
    "Name": "Iris-versicolor"
  },
 "Iris-virginica":  {
    "SepalLength": "6.3",
    "SepalWidth": "3.3",
    "PetalLength": "6.0",
    "PetalWidth": "2.5",
    "Name": "Iris-virginica"
  }
]

This would make for easier search in large JSON files so that you don't have to loop through each object and look for the Name, rather loop through each object with key Name.

Allow Conversion From JSON/CSV Strings

Currently, the package only supports converting from file inputs.

The package needs a new method like fromString(), where users can convert JSON/CSV strings to CSV/JSV strings without input files.

Allow conversion from strings

Currently, the package only supports converting from files, an issue mentioned before in #15.

The package needs a new method like fromString(), where users can convert JSON/CSV strings to CSV/JSV strings without input files.

Implement a Better Conversion Method for JSON to CSV

Currently, it is assumed that each object shares the same properties while converting JSON to CSV. So if one object has a property that the other one does not have, then it becomes a major problem.

So one should implement a better conversion method where it would not fail with objects that do not share the same properties.

Example Input:

[
  {
    "x": 0,
    "y": 1
  },
  {
    "y": 0,
    "z": 0
  }
]

Output: (Wrong)

x y
0 1
0 0

Expected Output: (True)

x y z
0 1 null
null 0 0

Is this production ready?

If it is production ready, can you please update the tag/version to be 1.0.0?

If it is not production ready, what are your concerns?

Thanks

Implement Nested Reverse Conversion Method from CSV to JSON

Currently, when one uses the output of JSON to CSV conversion as an input of CSV to JSON, one does not get the same input provided in the first place.

Example Scenario:

$csv = (new Json('whatever.json'))->convertAndSave('whatever.csv');
$json = (new Csv('whatever.csv'))->convertAndSave('whatever-new.json');
file_get_contents('whatever.json') === file_get_contents('whatever-new.json');

Here are the input and the output files for the example scenario.

Input: whatever.json

[
  {
    "name": {
      "common": "Turkey"
    },
    "latlng": [39, 35]
  }
]

Output: whatever.csv

name_common latlng_0 latlng_1
Turkey 39 35

Output: whatever-2.json

[{"name_common":"Turkey","latlng_0":"39","latlng_1":"35"}]

What is expected is a new method when used converts whatever.csv to whatever.json again instead of whatever-2.json.

Create More Tests with Complex Data

Probably this package has some bugs that can be identified with new tests. With taking inspiration from the current tests located in CsvTest.php and JsonTest.php files, you may create or modify some tests with more complex data.

What I mean by complex data is nested data like the below one.

{
  "a": {
    "b": {
      "c": 1,
      "d": {
        "e": [
          {
            "f": 2,
            "g": 3
          }
        ]
      }
    }
  }
}

TLDR: Create new tests to make package fail.

Can't convert JSON file

Hey man ! โœ‹

I used your library for my work to convert some JSON files to CSV but for some of this files, I have an arror message like this :
image

Do you have a answer to this problem ?

Thank you ^^

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.