Reeformatting a large non-rectangular file with mixed format

1 view (last 30 days)
Dear Matlab community,
I'm somewhat at beginner level of Matlab scripting and have urge to scan, write down, then edit and reformat a rather large, non-square mixed format file. This seems to be an absolute nightmare with using textscan or scanf functions. The fact of the matter is that the format of the file may vary and the number of lines and/or columns or sparsity of the file is subject to change.
Maybe someone can recommend a path associated with less pain. I'm including an approximate example of the input file format. Any advices are welcome, thanks in advace!
Model file created by ABCsoftware 8 2 1 11 20101101_003902_200_01_000001_004257.tem 2 11 20101101_003903_400_01_000001_004258.tem 3 11 20101101_003904_600_01_000001_004259.tem 4 11 20101101_003905_800_01_000001_004260.tem 5 11 20101101_003907_000_01_000001_004261.tem 6 11 20101101_003908_200_01_000001_004262.tem 7 11 20101101_003909_400_01_000001_004263.tem 8 11 20101101_003910_600_01_000001_004264.tem 50 20 662005.0 7271625.5 550.6 5.1000e+01 -1.0000e+00 1.5030e+00 5.3445e-01 5.1000e+01 -1.0000e+00 1.5030e+00 5.3445e-01 5.1000e+01 -1.0000e+00 1.5030e+00 5.3445e-01 5.1000e+01 -1.0000e+00 1.5030e+00 5.3445e-01 5.1000e+01 -1.0000e+00 1.5030e+00 5.3445e-01 5.1000e+01 -1.0000e+00 1.5030e+00 5.3445e-01 5.1000e+01 -1.0000e+00 1.5030e+00 5.3445e-01 5.1000e+01 -1.0000e+00 1.5030e+00 5.3445e-01 5.1000e+01 -1.0000e+00 1.5030e+00 5.3445e-01 5.1000e+01 -1.0000e+00 1.5030e+00 5.3445e-01 5.1000e+01 -1.0000e+00 1.5030e+00 5.3445e-01 5.1000e+01 -1.0000e+00 1.5030e+00 5.3445e-01 5.1000e+01 -1.0000e+00 1.5030e+00 5.3445e-01 5.1000e+01 -1.0000e+00 1.5030e+00 5.3445e-01 5.1000e+01 -1.0000e+00 1.5030e+00 5.3445e-01 5.1000e+01 -1.0000e+00 1.5030e+00 5.3445e-01 5.1000e+01 -1.0000e+00 1.5030e+00 5.3445e-01 5.1000e+01 -1.0000e+00 1.5030e+00 5.3445e-01 5.1000e+01 -1.0000e+00 1.5030e+00 5.3445e-01 5.1000e+01 -1.0000e+00 5.3445e-01 5.1020e+01 -1.0000e+00 1.0020e+00 5.3445e-01 5.1020e+01 -1.0000e+00 1.0020e+00 5.3445e-01 5.1020e+01 -1.0000e+00 1.0020e+00 5.3445e-01 5.1020e+01 -1.0000e+00 1.0020e+00 5.3445e-01 5.1020e+01 -1.0000e+00 1.0020e+00 5.3445e-01 5.1020e+01 -1.0000e+00 1.0020e+00 5.3445e-01 5.1020e+01 -1.0000e+00 1.0020e+00 5.3445e-01 5.1020e+01 -1.0000e+00 1.0020e+00 5.3445e-01 5.1020e+01 -1.0000e+00 1.0020e+00 5.3445e-01 5.1020e+01 -1.0000e+00 1.0020e+00 5.3445e-01 5.1020e+01 -1.0000e+00 1.0020e+00 5.3445e-01 5.1020e+01 -1.0000e+00 1.0020e+00 5.3445e-01 5.1020e+01 -1.0000e+00 1.0020e+00 5.3445e-01 5.1020e+01 -1.0000e+00 1.0020e+00 5.3445e-01 5.1020e+01 -1.0000e+00 1.0020e+00 5.3445e-01 5.1020e+01 -1.0000e+00 1.0020e+00 5.3445e-01 5.1020e+01 -1.0000e+00 1.0020e+00 5.3445e-01 5.1020e+01 -1.0000e+00 1.0020e+00 5.3445e-01 5.1020e+01 -1.0000e+00 1.0020e+00 5.3445e-01 5.1020e+01 -1.0000e+00 5.3445e-01 5.0030e-03 -1.0000e+00 1.0030e+00 1.3445e-01 5.0030e-03 -1.0000e+00 1.0030e+00 1.3445e-01 5.0030e-03 -1.0000e+00 1.0030e+00 1.3445e-01 5.0030e-03 -1.0000e+00 1.0030e+00 1.3445e-01 5.0030e-03 -1.0000e+00 1.0030e+00 1.3445e-01 5.0030e-03 -1.0000e+00 1.0030e+00 1.3445e-01 5.0030e-03 -1.0000e+00 1.0030e+00 1.3445e-01 5.0030e-03 -1.0000e+00 1.0030e+00 1.3445e-01 5.0030e-03 -1.0000e+00 1.0030e+00 1.3445e-01 5.0030e-03 -1.0000e+00 1.0030e+00 1.3445e-01 5.0030e-03 -1.0000e+00 1.0030e+00 1.3445e-01 5.0030e-03 -1.0000e+00 1.0030e+00 1.3445e-01 5.0030e-03 -1.0000e+00 1.0030e+00 1.3445e-01 5.0030e-03 -1.0000e+00 1.0030e+00 1.3445e-01 5.0030e-03 -1.0000e+00 1.0030e+00 1.3445e-01 5.0030e-03 -1.0000e+00 1.0030e+00 1.3445e-01 5.0030e-03 -1.0000e+00 1.0030e+00 1.3445e-01 5.0030e-03 -1.0000e+00 1.0030e+00 1.3445e-01 5.0030e-03 -1.0000e+00 1.0030e+00 1.3445e-01 1.0030e-02 -1.0000e+00 5.3445e-01 4.1040e-01 -1.0000e+00 1.0040e-02 1.0041e-02 4.1040e-01 -1.0000e+00 1.0040e-02 1.0041e-02
  1 Comment
dpb
dpb on 22 Feb 2015
"_...the format of the file may vary and the number of lines and/or columns or sparsity of the file is subject to change."_
Well that's a nightmare no matter what. If there are no clues about the number of elements per record based on something you can read from the file or a priori knowledge then it's a nightmare no matter what tool you use...
In that case there's really nothing to be done other than parsing the file on a line by line basis; then scan the line to determine what it contains and how many elements.
Who ever created such should have to supply the code to read it...

Sign in to comment.

Answers (0)

Categories

Find more on Environment and Settings in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!