How to read a specific line from multiple text files and save as an 'output.csv' file?

3 views (last 30 days)
I have multiple text files. I want to read a particlar line from those text files and combine them together in a separate text file as an output. If I want to read line number 69 from each files and write in a separate text file (or csv) as an output, How can I do that? I have attached three text files and I am expecting output like I have attached.

Answers (1)

Apoorv Singh
Apoorv Singh on 10 Jul 2020
For each text file, you can read the contents line by line (link). Reading a specific line number could be done by using a normal counter variable. Once you have the contents of the line, save it to an array. You can then write the contents to a csv file using writematrix (link).
Hope this helps :).

Categories

Find more on Text Data Preparation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!