download part of ascii file

4 visualizzazioni (ultimi 30 giorni)
Hi can anybody please share a code:
my ascii file is too big I want to download it by parts.
When I am trying to use
k=dlmread('11032020_2020-11-25_17-40-55_m1.ascii', ' ',[585 3 1457 4])
to read for example from line 585 to 1457 and from column 3 to 4 it gives me this error
Error using dlmread (line 147) Mismatch between file and format character vector. Trouble reading 'Numeric' field from file (row number 1, field number 5) ==> :06:03.154 PM,-0.0432,0.0235\n
file looks like this:
# File crea ted Wednesda y, N ovember 25, 2020 17:41:08 (UTC 0300)
# User Name : CalderonLa bTel emetry
# Time of f irst sample: 1 1/3/202 0 5:06:02.000 PM
# Time of l ast sample: 11 /4/2020 5:08:08.400 PM
# Col 2:HD- X02 (1099806 ), E EG, RAW , mV, Sample Rate: 500.00
# Col 3:HD- X02 (1099806 ), E MG, RAW , mV, Sample Rate: 500.00
Time ,HD -X02 (109980 6):I nput,HD -X02 (1099806):Input
11/3/2020 5:06:03.066 PM, 0.0156, -0.0523
11/3/2020 5:06:03.068 PM, 0.0401, -0.0081
11/3/2020 5:06:03.070 PM, 0.0198, 0.0315
11/3/2020 5:06:03.072 PM, -0.0329 ,0.0478
11/3/2020 5:06:03.074 PM, -0.0514 ,0.0450
11/3/2020 5:06:03.076 PM, -0.0205 ,0.0472
11/3/2020 5:06:03.078 PM, 0.0058, 0.0663
11/3/2020 5:06:03.080 PM, -0.0022 ,0.0849

Risposta accettata

Walter Roberson
Walter Roberson il 1 Dic 2020
k=dlmread('11032020_2020-11-25_17-40-55_m1.ascii', ' ',[585 3 1457 4])
asks it to skip 3 columns and that the reading should proceed to the column that would be skipping 4 columns. Writing that a less confusing way: it asks to read column 4 to 5.
The delimiter has been set to space, and
When a delimiter is inferred from the formatting of the file,
consecutive whitespaces are treated as a single delimiter. By
contrast, if a delimiter is specified by the DELIMITER input, any
repeated delimiter character is treated as a separate delimiter.
so when we examine
11/3/2020 5:06:03.078 PM, 0.0058, 0.0663
1234 567 89A BC DE
15 delimiters and columns 4 is empty and column 5 is '11/3/2020' which is not numeric.
The error message implies that it treated the hour 5 as column 4, and that then it is positioned to the beginning of ':06:03.154 PM,-0.0432,0.0235' looking to read a numeric value. But that location begins with ":'
If you had used comma as the delimiter than 0.0058 and 0.0663 would be columns 2 and 3, which would be suitable for [585 1 1457 2] range.

Più risposte (0)

Categorie

Scopri di più su Downloads in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by