How to write specific lines of a text file into the several output files in certain defined places. ( rephrased version)

1 次查看(过去 30 天)
Hello-- I was asked to rephrase my question in order to make it more useful to others! Please assume we have a large text file, I need to read a specific line in every 10 lines of the text file and write that line in another text file at the defined location of (A,B).
Please note for every 10 lines of the input file we need a distinct and separated output file. I hope this question finally get an answer :D Best,

回答(1 个)

Walter Roberson
Walter Roberson 2015-5-6
Have a look at textscan() using the N option to limit the number of lines you input. You can search for my contributions that mention textscan() as I have given several examples in the past.
As you have a large number of columns, you may wish to construct the format. See for example http://www.mathworks.com/matlabcentral/answers/27882-unable-to-import-data-with-textscan#comment_60999
  1 个评论
Homayoon
Homayoon 2015-5-6
Thanks Walter! But what i need is not the one u have addressed! As an example i need to read the specific characters in a determined line and place it in an output text file at specefic location! And repeat this procedure for every n lines of the input file! For example: Line 6 ,all characters between (6,12) to (6,18) should be copied to a new text file at (12,13) to (12,19) for instance. That is line 12 of the output And then do the same for line 16,26 and so on Your answer might not address all of my needs

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Text Data Preparation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by