我有一个csv文件,其中所有数据都在
一列中 A
8;a5747dfae47cccc8;7382625596;Anil;2017-08-07 16:51:58.753
9;a5747dfae47cccc8;7382625596;Anil;2017-08-07 17:21:11.416
10;a5747dfae47cccc8;7382625596;Anil;2017-08-07 17:41:09.771
11;a5747dfae47cccc8;7382625596;Anil;2017-08-07 18:01:22.448
我想要
A B C D E
8 a5747dfae47cccc8 7382625596 Anil 2017-08-07 16:51:58.753
9 a5747dfae47cccc8 7382625596 Anil 2017-08-07 17:21:11.416
10 a5747dfae47cccc8 7382625596 Anil 2017-08-07 17:41:09.771
11 a5747dfae47cccc8 7382625596 Anil 2017-08-07 18:01:22.448
答案 0 :(得分:0)
如果添加“ A; B; C; D; E”,您将拥有所需的内容:这是带有“;”的五列CSV作为字段分隔符
$posts = Post::where('status', 'active')
->with(['creator.avatar','group'])
->get();
$posts->transform(function($post) {
$post->title = 'Transformed'; // works
$post->creator->avatar = ['path'=>'/avatar/','file_name'=>'a.png']; // does not work
});
如果要使用命令行,则必须删除第一行(我使用sed),然后漂亮地打印输入内容(我使用Miller https://github.com/johnkerl/miller)
使用
A;B;C;D;E
8;a5747dfae47cccc8;7382625596;Anil;2017-08-07 16:51:58.753
9;a5747dfae47cccc8;7382625596;Anil;2017-08-07 17:21:11.416
10;a5747dfae47cccc8;7382625596;Anil;2017-08-07 17:41:09.771
11;a5747dfae47cccc8;7382625596;Anil;2017-08-07 18:01:22.448
您将拥有
<input.csv sed -e '1,1d' | mlr --n2p --ifs ";" then label A,B,C,D,E