Extract data from text file

Hello! Please help me. I need a code to extract data from a large text file.
This includes data like this:
146.204.224.152 - feest6811 [21/Jun/2019:15:45:24 -0700] "POST /incentivize HTTP/1.1" 302 4622
197.109.77.178 - kertzmann3129 [21/Jun/2019:15:45:25 -0700] "DELETE /virtual/solutions/target/web+services HTTP/2.0" 203 26554
156.127.178.177 - okuneva5222 [21/Jun/2019:15:45:27 -0700] "DELETE /interactive/transparent/niches/revolutionize HTTP/1.1" 416 14701
159.253.153.40 - - [21/Jun/2019:15:46:10 -0700] "POST /e-business HTTP/1.0" 504 19845
100.32.205.59 - ortiz8891 [21/Jun/2019:15:45:28 -0700] "PATCH /architectures HTTP/1.0" 204 6048
233.187.15.207 - - [21/Jun/2019:15:46:14 -0700] "GET /harness/intuitive HTTP/1.0" 304 21006
168.95.156.240 - stark2413 [21/Jun/2019:15:45:31 -0700] "GET /engage HTTP/2.0" 201 9645
It is needed to be converted into a list of strings like this:
"host: 146.204.224.152"
"username: feest6811"
"time: 21/Jun/2019:15:45:24 -0700"
"request: POST /incentivize HTTP/1.1"
sometimes there are no username so instead it is changed into a dash line

 采纳的回答

Mario Malic
Mario Malic 2020-11-1
编辑:Mario Malic 2020-11-2

1 个投票

I am going to post this as an answer without it being one, this question has been answered few times already in the last couple of days, here are some links to the questions:

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Standard File Formats 的更多信息

产品

版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by