22[ ![ 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 )
33[ ![ 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 )
44
5-
6-
7-
8-
95** A simple php file helper** ✨
106
11-
12-
137==========================================
148
159** Installation**
@@ -19,36 +13,39 @@ composer require rcsofttech85/file-handler
1913
2014```
2115
22-
2316** search by a keyword in file**
2417
2518```
26- $fileHandler = new FileHandler();
19+ $temp = new TempFileHandler();
20+ $csv = new CsvFileHandler($temp);
21+
22+ $findByKeyword = $csv->searchInCsvFile("movies.csv","Twilight","Film");
2723
28- $fileHandler->open(filename: 'movie.csv',mode:'r')->searchInCsvFile(keyword: 'Twilight',column:'Film');
2924
3025```
3126
3227** search by a keyword in file and return array**
3328
3429```
35- $fileHandler = new FileHandler();
30+ $temp = new TempFileHandler();
31+ $csv = new CsvFileHandler($temp);
3632
37- $fileHandler->open(filename: 'movie. csv',mode:'r') ->searchInCsvFile(keyword: 'Zack and Miri Make a Porno',column:' Film', format: FileHandler::ARRAY_FORMAT);
33+ $findByKeyword = $ csv->searchInCsvFile("movies.csv","Twilight"," Film", FileHandler::ARRAY_FORMAT);
3834
3935// output
4036
4137[
42- ' Film' => 'Zack and Miri Make a Porno',
43- ' Genre' => ' Romance',
44- ' Lead Studio' => 'The Weinstein Company',
45- ' Audience score %' => '70',
46- ' Profitability' => '1.747541667',
47- ' Rotten Tomatoes %' => '64',
48- ' Worldwide Gross' => '$41.94 ',
49- ' Year' => ' 2008'
38+ [ Film] => Twilight
39+ [ Genre] => Romance
40+ [ Lead Studio] => Summit
41+ [ Audience score %] => 82
42+ [ Profitability] => 10.18002703
43+ [ Rotten Tomatoes %] => 49
44+ [ Worldwide Gross] => $376.66
45+ [ Year] => 2008
5046
51- ];
47+
48+ ];
5249```
5350
5451** Write multiple file simultaneously:**
@@ -69,10 +66,11 @@ $fileHandler->close();
6966** converting file to an array**
7067
7168```
72- $fileHandler = new FileHandler();
7369
74- $data = $fileHandler->open(filename: 'movie.csv',mode:'r')->toArray();
70+ $temp = new TempFileHandler();
71+ $csv = new CsvFileHandler($temp);
7572
73+ $findByKeyword = $csv->toArray("movies.csv");
7674// output
7775$data[0] = [
7876 'Film' => 'Zack and Miri Make a Porno',
@@ -88,11 +86,36 @@ $data[0] = [
8886
8987```
9088
89+ ** Find and replace in csv file**
90+
91+ ```
92+
93+ $temp = new TempFileHandler();
94+ $csv = new CsvFileHandler($temp);
95+
96+ $findByKeyword = $csv->findAndReplaceInCsv("movies.csv","Twilight","Inception");
97+
98+ ```
99+
100+ ** Find and replace a specific keyword in a particular column of a CSV file**
101+
102+ ```
103+
104+ $temp = new TempFileHandler();
105+ $csv = new CsvFileHandler($temp);
106+
107+ $findByKeyword = $csv->findAndReplaceInCsv("movies.csv","Inception","Twilight",column: "Film");
108+
109+ ```
110+
91111** converting file to a json format**
92112
93113```
94- $fileHandler = new FileHandler();
95- $this->fileHandler->open(filename: 'movie.csv')->toJson();
114+
115+ $temp = new TempFileHandler();
116+ $csv = new CsvFileHandler($temp);
117+
118+ $findByKeyword = $csv->toJson("movies.csv");
96119
97120//output
98121[{"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"}]
@@ -160,7 +183,7 @@ vendor/bin/file-diff oldFile newFile
160183
161184```
162185
163- ** File Integrity**
186+ ** File Integrity check **
164187
165188```
166189$fileHasher = new FileHashChecker();
0 commit comments