質問編集履歴
5
進んだ処理まで記述
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,11 +30,19 @@
|
|
30
30
|
|
31
31
|
|
32
32
|
|
33
|
-
|
33
|
+
Storage::disk('local')->writeStream(
|
34
34
|
|
35
|
-
|
35
|
+
'dm.csv',
|
36
36
|
|
37
|
+
Storage::disk('ftp')->readStream('sample.csv')
|
38
|
+
|
39
|
+
);
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
$file = new SplFileObject('/storage/app/dm.csv'); //ここでエラー発生
|
44
|
+
|
37
|
-
$
|
45
|
+
$file->setFlags(
|
38
46
|
|
39
47
|
\SplFileObject::READ_CSV |
|
40
48
|
|
@@ -48,7 +56,7 @@
|
|
48
56
|
|
49
57
|
|
50
58
|
|
51
|
-
foreach($
|
59
|
+
foreach($file as $record) {
|
52
60
|
|
53
61
|
var_dump($record);
|
54
62
|
|
@@ -68,9 +76,13 @@
|
|
68
76
|
|
69
77
|
上記のコードで実行。
|
70
78
|
|
71
|
-
|
79
|
+
一時的にapp配下に保存し、保存したdm.csvをSplFileObjectの処理にかけて以下のエラーが発生
|
72
80
|
|
73
|
-
|
81
|
+
```
|
82
|
+
|
83
|
+
RuntimeException : SplFileObject::__construct(/storage/app/sample.csv): failed to open stream: No such file or directory
|
84
|
+
|
85
|
+
```
|
74
86
|
|
75
87
|
|
76
88
|
|
@@ -78,4 +90,4 @@
|
|
78
90
|
|
79
91
|
|
80
92
|
|
81
|
-
Laravel, Mysql
|
93
|
+
Laravel5.8, Mysql
|
4
エラーが起こる箇所にコメント
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
|
33
33
|
$file = Storage::disk('ftp')->get('sample.csv');
|
34
34
|
|
35
|
-
$csv = new \SplFileObject($file->getRealPath());
|
35
|
+
$csv = new \SplFileObject($file->getRealPath()); //ここでエラー
|
36
36
|
|
37
37
|
$csv->setFlags(
|
38
38
|
|
3
全体的に質問修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,27 +26,35 @@
|
|
26
26
|
|
27
27
|
{
|
28
28
|
|
29
|
-
setlocale(LC_ALL, 'ja_JP.
|
29
|
+
setlocale(LC_ALL, 'ja_JP.UTF-8');
|
30
30
|
|
31
31
|
|
32
32
|
|
33
|
-
$file = Storage::disk('ftp')->get('sample.csv');
|
33
|
+
$file = Storage::disk('ftp')->get('sample.csv');
|
34
34
|
|
35
|
-
|
35
|
+
$csv = new \SplFileObject($file->getRealPath());
|
36
36
|
|
37
|
-
$
|
37
|
+
$csv->setFlags(
|
38
38
|
|
39
|
-
|
39
|
+
\SplFileObject::READ_CSV |
|
40
40
|
|
41
|
-
|
41
|
+
\SplFileObject::READ_AHEAD |
|
42
42
|
|
43
|
-
|
43
|
+
\SplFileObject::SKIP_EMPTY |
|
44
44
|
|
45
|
-
|
45
|
+
\SplFileObject::DROP_NEW_LINE
|
46
|
+
|
47
|
+
);
|
46
48
|
|
47
49
|
|
48
50
|
|
51
|
+
foreach($csv as $record) {
|
52
|
+
|
49
|
-
r
|
53
|
+
var_dump($record);
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
exit;
|
50
58
|
|
51
59
|
}
|
52
60
|
|
@@ -58,25 +66,11 @@
|
|
58
66
|
|
59
67
|
|
60
68
|
|
61
|
-
|
69
|
+
上記のコードで実行。
|
62
70
|
|
63
|
-
|
71
|
+
Symfony\Component\Debug\Exception\FatalThrowableError : Call to a member function getRealPath() on string
|
64
72
|
|
65
|
-
$text = explode(' ', $csv_data);
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
foreach ($text as $key => $value) {
|
70
|
-
|
71
|
-
$text[$key] = explode(',', $value);
|
72
|
-
|
73
|
-
}
|
74
|
-
|
75
|
-
```
|
76
|
-
|
77
|
-
上記のようなコーディングで配列ができるかなと思ったが、
|
78
|
-
|
79
|
-
|
73
|
+
というエラーが発生し先に進まず
|
80
74
|
|
81
75
|
|
82
76
|
|
2
csvデータサイズの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
FTP接続にて取得したCSVデータをTableに保存を行う。
|
5
|
+
FTP接続にて取得したCSVデータ(134217728 bytes)をTableに保存を行う。
|
6
6
|
|
7
7
|
|
8
8
|
|
1
わかりやすいように修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,11 +30,11 @@
|
|
30
30
|
|
31
31
|
|
32
32
|
|
33
|
-
$file = Storage::disk('ftp')->get('sample.csv');
|
33
|
+
$file = Storage::disk('ftp')->get('sample.csv');//ここまでは順調
|
34
34
|
|
35
35
|
//$file = new \SplFileObject($file_path, 'rb');
|
36
36
|
|
37
|
-
$file->setFlags(\SplFileObject::READ_CSV |
|
37
|
+
$file->setFlags(\SplFileObject::READ_CSV |//ここで動かない
|
38
38
|
|
39
39
|
\SplFileObject::READ_AHEAD |
|
40
40
|
|