Dodaj skrypt do przetwarzania danych z pliku CSV i dekodowania JSON
This commit is contained in:
1021
millihome.pl/export.csv
Normal file
1021
millihome.pl/export.csv
Normal file
File diff suppressed because it is too large
Load Diff
27
millihome.pl/index.php
Normal file
27
millihome.pl/index.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?
|
||||
$content = file_get_contents( 'export.csv' );
|
||||
$lines = explode( "\n", $content );
|
||||
$header = explode( ',', array_shift( $lines ) );
|
||||
|
||||
for ( $i = 1; $i < count( $lines ); $i++ ) {
|
||||
|
||||
$data = str_getcsv( $lines[$i] );
|
||||
|
||||
$json_field = $data[7] ?? null;
|
||||
if ( $json_field ) {
|
||||
|
||||
$json_data = json_decode( $json_field, true );
|
||||
if ( json_last_error() === JSON_ERROR_NONE ) {
|
||||
|
||||
$rate = json_decode( $json_data['rate'], true ); var_dump( $rate );
|
||||
// $rate = json_decode( $json_data[7]['rate'], true ); print_r( $rate ); exit;
|
||||
// if ( $rate ) {
|
||||
// $json_data[7]['rate'] = $rate;
|
||||
// }
|
||||
$data[7] = $json_data;
|
||||
}
|
||||
}
|
||||
|
||||
// print_r( $data );
|
||||
exit;
|
||||
}
|
||||
Reference in New Issue
Block a user