嗨,我有一个文本文件 sample.txt 作为
=====record1
title:javabook
price:$120
author:john
path:d:
=====record2
title:.netbook
author:paul
path:f:
=====record3
author:john
title:phpbook
subject:php
path:f:
price:$150
=====record4
title:phpbook
subject:php
path:f:
price:$150
从这里我想根据作者拆分数据,它应该分成2个文件,其中包含
test1.txt
=====record1
title:javabook
price:$120
author:john
path:d:
=====record3
author:john
title:phpbook
subject:php
path:f:
price:$150
和
test2.txt
=====record2
title:.netbook
author:paul
path:f:
像上面一样,我想根据作者字段动态地将主 sample.txt 文件分类为子文件,请建议我一种方法。