Skip to content

Commit

Permalink
first version
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecc committed Dec 5, 2021
1 parent 55ec596 commit 60ce120
Show file tree
Hide file tree
Showing 10 changed files with 702 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/composer.lock
23 changes: 23 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "eftec/filetextone",
"description": "a library to work with json and csv",
"type": "library",
"require-dev": {
"phpunit/phpunit": "^9.5"
},
"license": "MIT",
"autoload": {
"psr-4": {
"Eftec\\FileTextOne\\": "src/"
}
},
"authors": [
{
"name": "Jorge Castro",
"email": "[email protected]"
}
],
"require": {
"ext-json": "*"
}
}
63 changes: 63 additions & 0 deletions examples/dolar.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
"fecha","valor"
"2021-12-01T03:00:00.000000Z",837.55
"2021-11-30T03:00:00.000000Z",836.73
"2021-11-29T03:00:00.000000Z",829.94
"2021-11-26T03:00:00.000000Z",819.59
"2021-11-25T03:00:00.000000Z",811.7
"2021-11-24T03:00:00.000000Z",809.94
"2021-11-23T03:00:00.000000Z",808.14
"2021-11-22T03:00:00.000000Z",832.72
"2021-11-19T03:00:00.000000Z",834.57
"2021-11-18T03:00:00.000000Z",819.56
"2021-11-17T03:00:00.000000Z",806.24
"2021-11-16T03:00:00.000000Z",801.96
"2021-11-15T03:00:00.000000Z",797.8
"2021-11-12T03:00:00.000000Z",791.3
"2021-11-11T03:00:00.000000Z",791.71
"2021-11-10T03:00:00.000000Z",797.78
"2021-11-09T03:00:00.000000Z",806.61
"2021-11-08T03:00:00.000000Z",812.4
"2021-11-05T03:00:00.000000Z",815.58
"2021-11-04T03:00:00.000000Z",815.52
"2021-11-03T03:00:00.000000Z",814.42
"2021-11-02T03:00:00.000000Z",810.91
"2021-10-29T03:00:00.000000Z",805.47
"2021-10-28T03:00:00.000000Z",804.32
"2021-10-27T03:00:00.000000Z",806.55
"2021-10-26T03:00:00.000000Z",810.16
"2021-10-25T03:00:00.000000Z",816.58
"2021-10-22T03:00:00.000000Z",817.61
"2021-10-21T03:00:00.000000Z",811.55
"2021-10-20T03:00:00.000000Z",813.33
"2021-10-19T03:00:00.000000Z",820.29
"2021-12-01T03:00:00.000000Z",837.55
"2021-11-30T03:00:00.000000Z",836.73
"2021-11-29T03:00:00.000000Z",829.94
"2021-11-26T03:00:00.000000Z",819.59
"2021-11-25T03:00:00.000000Z",811.7
"2021-11-24T03:00:00.000000Z",809.94
"2021-11-23T03:00:00.000000Z",808.14
"2021-11-22T03:00:00.000000Z",832.72
"2021-11-19T03:00:00.000000Z",834.57
"2021-11-18T03:00:00.000000Z",819.56
"2021-11-17T03:00:00.000000Z",806.24
"2021-11-16T03:00:00.000000Z",801.96
"2021-11-15T03:00:00.000000Z",797.8
"2021-11-12T03:00:00.000000Z",791.3
"2021-11-11T03:00:00.000000Z",791.71
"2021-11-10T03:00:00.000000Z",797.78
"2021-11-09T03:00:00.000000Z",806.61
"2021-11-08T03:00:00.000000Z",812.4
"2021-11-05T03:00:00.000000Z",815.58
"2021-11-04T03:00:00.000000Z",815.52
"2021-11-03T03:00:00.000000Z",814.42
"2021-11-02T03:00:00.000000Z",810.91
"2021-10-29T03:00:00.000000Z",805.47
"2021-10-28T03:00:00.000000Z",804.32
"2021-10-27T03:00:00.000000Z",806.55
"2021-10-26T03:00:00.000000Z",810.16
"2021-10-25T03:00:00.000000Z",816.58
"2021-10-22T03:00:00.000000Z",817.61
"2021-10-21T03:00:00.000000Z",811.55
"2021-10-20T03:00:00.000000Z",813.33
"2021-10-19T03:00:00.000000Z",820.29
133 changes: 133 additions & 0 deletions examples/dolar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
"version": "1.7.0",
"autor": "mindicador.cl",
"codigo": "dolar",
"nombre": "Dólar observado",
"unidad_medida": "Pesos",
"serie": [
{
"fecha": "2021-12-01T03:00:00.000Z",
"valor": 837.55
},
{
"fecha": "2021-11-30T03:00:00.000Z",
"valor": 836.73
},
{
"fecha": "2021-11-29T03:00:00.000Z",
"valor": 829.94
},
{
"fecha": "2021-11-26T03:00:00.000Z",
"valor": 819.59
},
{
"fecha": "2021-11-25T03:00:00.000Z",
"valor": 811.7
},
{
"fecha": "2021-11-24T03:00:00.000Z",
"valor": 809.94
},
{
"fecha": "2021-11-23T03:00:00.000Z",
"valor": 808.14
},
{
"fecha": "2021-11-22T03:00:00.000Z",
"valor": 832.72
},
{
"fecha": "2021-11-19T03:00:00.000Z",
"valor": 834.57
},
{
"fecha": "2021-11-18T03:00:00.000Z",
"valor": 819.56
},
{
"fecha": "2021-11-17T03:00:00.000Z",
"valor": 806.24
},
{
"fecha": "2021-11-16T03:00:00.000Z",
"valor": 801.96
},
{
"fecha": "2021-11-15T03:00:00.000Z",
"valor": 797.8
},
{
"fecha": "2021-11-12T03:00:00.000Z",
"valor": 791.3
},
{
"fecha": "2021-11-11T03:00:00.000Z",
"valor": 791.71
},
{
"fecha": "2021-11-10T03:00:00.000Z",
"valor": 797.78
},
{
"fecha": "2021-11-09T03:00:00.000Z",
"valor": 806.61
},
{
"fecha": "2021-11-08T03:00:00.000Z",
"valor": 812.4
},
{
"fecha": "2021-11-05T03:00:00.000Z",
"valor": 815.58
},
{
"fecha": "2021-11-04T03:00:00.000Z",
"valor": 815.52
},
{
"fecha": "2021-11-03T03:00:00.000Z",
"valor": 814.42
},
{
"fecha": "2021-11-02T03:00:00.000Z",
"valor": 810.91
},
{
"fecha": "2021-10-29T03:00:00.000Z",
"valor": 805.47
},
{
"fecha": "2021-10-28T03:00:00.000Z",
"valor": 804.32
},
{
"fecha": "2021-10-27T03:00:00.000Z",
"valor": 806.55
},
{
"fecha": "2021-10-26T03:00:00.000Z",
"valor": 810.16
},
{
"fecha": "2021-10-25T03:00:00.000Z",
"valor": 816.58
},
{
"fecha": "2021-10-22T03:00:00.000Z",
"valor": 817.61
},
{
"fecha": "2021-10-21T03:00:00.000Z",
"valor": 811.55
},
{
"fecha": "2021-10-20T03:00:00.000Z",
"valor": 813.33
},
{
"fecha": "2021-10-19T03:00:00.000Z",
"valor": 820.29
}
]
}
17 changes: 17 additions & 0 deletions examples/grades.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"Last name", "First name", "SSN", "Test1", "Test2", "Test3", "Test4", "Final", "Grade"
"Alfalfa", "Aloysius", "123-45-6789", 40.0, 90.0, 100.0, 83.0, 49.0, "D-"
"Alfred", "University", "123-12-1234", 41.0, 97.0, 96.0, 97.0, 48.0, "D+"
"Gerty", "Gramma", "567-89-0123", 41.0, 80.0, 60.0, 40.0, 44.0, "C"
"Android", "Electric", "087-65-4321", 42.0, 23.0, 36.0, 45.0, 47.0, "B-"
"Bumpkin", "Fred", "456-78-9012", 43.0, 78.0, 88.0, 77.0, 45.0, "A-"
"Rubble", "Betty", "234-56-7890", 44.0, 90.0, 80.0, 90.0, 46.0, "C-"
"Noshow", "Cecil", "345-67-8901", 45.0, 11.0, -1.0, 4.0, 43.0, "F"
"Buff", "Bif", "632-79-9939", 46.0, 20.0, 30.0, 40.0, 50.0, "B+"
"Airpump", "Andrew", "223-45-6789", 49.0 1.0, 90.0, 100.0, 83.0, "A"
"Backus", "Jim", "143-12-1234", 48.0, 1.0, 97.0, 96.0, 97.0, "A+"
"Carnivore", "Art", "565-89-0123", 44.0, 1.0, 80.0, 60.0, 40.0, "D+"
"Dandy", "Jim", "087-75-4321", 47.0, 1.0, 23.0, 36.0, 45.0, "C+"
"Elephant", "Ima", "456-71-9012", 45.0, 1.0, 78.0, 88.0, 77.0, "B-"
"Franklin", "Benny", "234-56-2890", 50.0, 1.0, 90.0, 80.0, 90.0, "B-"
"George", "Boy", "345-67-3901", 40.0, 1.0, 11.0, -1.0, 4.0, "B"
"Heffalump", "Harvey", "632-79-9439", 30.0, 1.0, 20.0, 30.0, 40.0, "C"
1 change: 1 addition & 0 deletions examples/new.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"id":"hello","field":20},{"id":"hello","field":20},{"id":"hello","field":20},{"id":"hello","field":20}]
27 changes: 27 additions & 0 deletions examples/test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

use eftec\FileTextOne;

error_reporting(E_STRICT);
include '../vendor/autoload.php';

$filetextoone=new FileTextOne('csv','grades.csv');
$filetextoone->setCsvStyle(',','"',true,"\n");
echo "<pre>";
$filetextoone->toAll();
//var_dump($filetextoone->toAll());
var_dump($filetextoone->columnTypes);
echo "</pre>";

$obj=[];
$obj["Last name"]= "Alfalfa";
$obj["First name"]= "Aloysius";
$obj["SSN"]="123-45-6789";
$obj["Test1"]=40;
$obj["Test2"]=90;
$obj["Test3"]=100;
$obj["Test4"]=83;
$obj["Final"]=49;
$obj["Grade"]= "D-";

$filetextoone->insert($obj);
21 changes: 21 additions & 0 deletions examples/testjson.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php



//ini_set('precision', 10);
//ini_set('serialize_precision', 10);


use Eftec\FileTextOne\FileTextOne;

include '../vendor/autoload.php';

$filetextoone=new FileTextOne('json','dolar.json');
$filetextoone->regionDateTime='Y-m-d\TH:i:s.u\Z';

$filecsv=new FileTextOne('csv','dolar.csv');
$filecsv->regionDateTime='Y-m-d\TH:i:s.u\Z';


$values=$filetextoone->toAll('serie');
$filecsv->insert($values);
11 changes: 11 additions & 0 deletions examples/testjsoninsert.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

use Eftec\FileTextOne\FileTextOne;

include '../vendor/autoload.php';

$values=[["id"=>"hello","field"=>20],["id"=>"hello","field"=>20]];

$fto=new FileTextOne('json','new.json');

$fto->insert($values);
Loading

0 comments on commit 60ce120

Please sign in to comment.