Skip to content

update readme #20

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

Merged
merged 1 commit into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 48 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/c6450a9c0f99488e93b34911f1adfb2e)](https://app.codacy.com/gh/rcsofttech85/php-file-helper/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/c6450a9c0f99488e93b34911f1adfb2e)](https://app.codacy.com/gh/rcsofttech85/php-file-helper/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage)





**A simple php file helper** ✨



==========================================

**Installation**
Expand All @@ -19,36 +13,39 @@ composer require rcsofttech85/file-handler

```


**search by a keyword in file**

```
$fileHandler = new FileHandler();
$temp = new TempFileHandler();
$csv = new CsvFileHandler($temp);

$findByKeyword = $csv->searchInCsvFile("movies.csv","Twilight","Film");

$fileHandler->open(filename: 'movie.csv',mode:'r')->searchInCsvFile(keyword: 'Twilight',column:'Film');

```

**search by a keyword in file and return array**

```
$fileHandler = new FileHandler();
$temp = new TempFileHandler();
$csv = new CsvFileHandler($temp);

$fileHandler->open(filename: 'movie.csv',mode:'r')->searchInCsvFile(keyword: 'Zack and Miri Make a Porno',column:'Film', format: FileHandler::ARRAY_FORMAT);
$findByKeyword = $csv->searchInCsvFile("movies.csv","Twilight","Film",FileHandler::ARRAY_FORMAT);

// output

[
'Film' => 'Zack and Miri Make a Porno',
'Genre' => 'Romance',
'Lead Studio' => 'The Weinstein Company',
'Audience score %' => '70',
'Profitability' => '1.747541667',
'Rotten Tomatoes %' => '64',
'Worldwide Gross' => '$41.94 ',
'Year' => '2008'
[Film] => Twilight
[Genre] => Romance
[Lead Studio] => Summit
[Audience score %] => 82
[Profitability] => 10.18002703
[Rotten Tomatoes %] => 49
[Worldwide Gross] => $376.66
[Year] => 2008

];

];
```

**Write multiple file simultaneously:**
Expand All @@ -69,10 +66,11 @@ $fileHandler->close();
**converting file to an array**

```
$fileHandler = new FileHandler();

$data = $fileHandler->open(filename: 'movie.csv',mode:'r')->toArray();
$temp = new TempFileHandler();
$csv = new CsvFileHandler($temp);

$findByKeyword = $csv->toArray("movies.csv");
// output
$data[0] = [
'Film' => 'Zack and Miri Make a Porno',
Expand All @@ -88,11 +86,36 @@ $data[0] = [

```

**Find and replace in csv file**

```

$temp = new TempFileHandler();
$csv = new CsvFileHandler($temp);

$findByKeyword = $csv->findAndReplaceInCsv("movies.csv","Twilight","Inception");

```

**Find and replace a specific keyword in a particular column of a CSV file**

```

$temp = new TempFileHandler();
$csv = new CsvFileHandler($temp);

$findByKeyword = $csv->findAndReplaceInCsv("movies.csv","Inception","Twilight",column: "Film");

```

**converting file to a json format**

```
$fileHandler = new FileHandler();
$this->fileHandler->open(filename: 'movie.csv')->toJson();

$temp = new TempFileHandler();
$csv = new CsvFileHandler($temp);

$findByKeyword = $csv->toJson("movies.csv");

//output
[{"Film":"Zack and Miri Make a Porno","Genre":"Romance","Lead Studio":"The Weinstein Company","Audience score %":"70","Profitability":"1.747541667","Rotten Tomatoes %":"64","Worldwide Gross":"$41.94 ","Year":"2008"},{"Film":"Youth in Revolt","Genre":"Comedy","Lead Studio":"The Weinstein Company","Audience score %":"52","Profitability":"1.09","Rotten Tomatoes %":"68","Worldwide Gross":"$19.62 ","Year":"2010"},{"Film":"Twilight","Genre":"Romance","Lead Studio":"Independent","Audience score %":"68","Profitability":"6.383363636","Rotten Tomatoes %":"26","Worldwide Gross":"$702.17 ","Year":"2011"}]
Expand Down Expand Up @@ -160,7 +183,7 @@ vendor/bin/file-diff oldFile newFile

```

**File Integrity**
**File Integrity check**

```
$fileHasher = new FileHashChecker();
Expand Down
1 change: 0 additions & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php


require 'vendor/autoload.php';
require 'tests/Base/BaseTest.php';