How to split a big text file based on specific strings?
12 views (last 30 days)
Show older comments
I am acquiring physiological data, during each routine of my experiment.
For each routine, I save the name of the routine, time, and data of 8 channels (a total of 9 columns), in a text file.
The entire text file is very big (>20Gb) and matlab cannot handle it fully. I added a sample of it below.
Each routine begins with the word "Routine", then the follwing row contains the headers and the following rows contains the data.
Could you please help me to:
- Extract the name of each routine and its row index
- Extract the 8 columns of values for each routine and save it in matrix ( and then in a .mat).
I tried to use textscan but I was not able to call correctly my data I guess
I tried strfind but it returned the starting indexe of each "Routine" but I did not know how to extract the rest of the line and or the values for each routine
I also looked into regexprep, fgetl etc. but I am slighlty lost on how to handle such big files as characters...
-------------------------------
sample of a file
Routine Signal Acq and Paramet with condition standard
Time [Val- channel1] [Val- channel2] [Val- channel3] [Val- channel4] [Tr-channel1] [Tr-channel2] [Tr-channel3] [Tr-channel4]
2.5936 -0.00054016 0.0066925 0.0017426 0.049998 0 0 0 0
4.0773 -0.00053864 0.0066956 0.0017456 0.049998 0 0 0 0
4.1159 -0.00054016 0.006694 0.0017456 0.049998 0 0 0 0
4.1469 -0.00054016 0.006694 0.0017426 0.049998 0 0 0 0
4.1511 -0.00054779 0.006694 0.0017395 0.049998 0 0 0 0
4.1531 -0.00054626 0.006694 0.0017395 0.049998 0 0 0 0
4.1553 -0.00054626 0.0066956 0.001741 0.049998 0 0 0 0
4.1584 -0.00054474 0.006694 0.0017426 0.049998 0 0 0 0
4.1619 -0.00054779 0.006694 0.0017456 0.049998 0 0 0 0
4.1653 -0.00053864 0.006694 0.0017456 0.049998 0 0 0 0
4.1686 -0.00053711 0.0066925 0.0017471 0.049998 0 0 0 0
4.1713 -0.00054016 0.0066895 0.001741 0.049998 0 0 0 0
4.1751 -0.00054932 0.006694 0.0017395 0.049998 0 0 0 0
4.1779 -0.00054474 0.006694 0.0017426 0.049998 0 0 0 0
4.1799 -0.00053406 0.0066925 0.0017502 0.049998 0 0 0 0
4.1827 -0.00053711 0.0066956 0.0017487 0.049998 0 0 0 0
4.1848 -0.00054016 0.0066925 0.0017471 0.049998 0 0 0 0
4.1875 -0.00054321 0.006694 0.0017441 0.049998 0 0 0 0
4.1903 -0.00053711 0.006694 0.0017471 0.049998 0 0 0 0
4.1923 -0.00054016 0.006694 0.0017502 0.049998 0 0 0 0
4.1943 -0.00053864 0.0066895 0.0017426 0.049998 0 0 0 0
4.1971 -0.00054169 0.006694 0.0017395 0.049998 0 0 0 0
4.1994 -0.00054626 0.0066956 0.0017441 0.049998 0 0 0 0
4.2018 -0.00054474 0.006694 0.0017487 0.049998 0 0 0 0
4.204 -0.00056 0.0066925 0.0017456 0.049998 0 0 0 0
4.2065 -0.00055389 0.0066956 0.0017426 0.049998 0 0 0 0
4.2966 -0.00054626 0.0066925 0.001741 0.049998 0 0 0 0
4.2992 -0.00054474 0.0066895 0.0017426 0.049998 0 0 0 0
4.3013 -0.00053711 0.006694 0.0017456 0.049998 0 0 0 0
4.3045 -0.00052643 0.0066925 0.0017502 0.049998 0 0 0 0
4.3068 -0.00053253 0.0066925 0.0017502 0.049998 0 0 0 0
4.3087 -0.00053406 0.006694 0.0017471 0.049998 0 0 0 0
4.311 -0.00053711 0.0066925 0.0017517 0.049998 0 0 0 0
4.3132 -0.00054169 0.0066956 0.0017532 0.049998 0 0 0 0
4.3155 -0.00053864 0.006694 0.0017532 0.049998 0 0 0 0
4.3179 -0.00053711 0.006694 0.0017471 0.049998 0 0 0 0
4.3207 -0.00052795 0.006694 0.0017532 0.049998 0 0 0 0
4.3237 -0.00052338 0.006694 0.0017532 0.049998 0 0 0 0
4.3265 -0.00053558 0.0066925 0.0017502 0.049998 0 0 0 0
4.3298 -0.00054779 0.0066925 0.0017441 0.049998 0 0 0 0
4.3319 -0.00054779 0.0066956 0.0017456 0.049998 0 0 0 0
4.334 -0.00055084 0.0066925 0.001741 0.049998 0 0 0 0
4.3358 -0.00054932 0.006694 0.0017441 0.049998 0 0 0 0
4.3378 -0.00055084 0.006694 0.0017502 0.049998 0 0 0 0
4.3398 -0.00055389 0.006694 0.0017532 0.049998 0 0 0 0
4.3426 -0.00055237 0.0066925 0.0017517 0.049998 0 0 0 0
4.345 -0.00053558 0.0066971 0.0017532 0.049998 0 0 0 0
4.3475 -0.00053101 0.0066971 0.0017441 0.049998 0 0 0 0
4.3496 -0.00053864 0.0066956 0.0017349 0.049998 0 0 0 0
4.3767 -0.00054474 0.006694 0.001738 0.049998 0 0 0 0
4.3796 -0.00054626 0.006694 0.0017426 0.049998 0 0 0 0
4.3814 -0.00053558 0.006694 0.0017456 0.049998 0 0 0 0
4.3831 -0.00052795 0.0066956 0.0017517 0.049998 0 0 0 0
4.3846 -0.00054169 0.0066971 0.0017365 0.049998 0 0 0 0
4.386 -0.00054779 0.0066956 0.0017319 0.049998 0 0 0 0
4.3876 -0.00053864 0.0066971 0.0017365 0.049998 0 0 0 0
4.3892 -0.00054016 0.0066956 0.0017441 0.049998 0 0 0 0
4.3908 -0.00054016 0.0066956 0.0017487 0.049998 0 0 0 0
4.3925 -0.00054932 0.0066956 0.0017441 0.049998 0 0 0 0
4.3943 -0.00054474 0.006694 0.0017395 0.049998 0 0 0 0
4.396 -0.00054016 0.0066956 0.0017365 0.049998 0 0 0 0
4.4216 -0.00054626 0.0066971 0.0017349 0.049998 0 0 0 0
4.4255 -0.00055237 0.0066971 0.0017288 0.049998 0 0 0 0
Routine Signal Acq and Paramet with condition standard
Time [Val- channel1] [Val- channel2] [Val- channel3] [Val- channel4] [Tr-channel1] [Tr-channel2] [Tr-channel3] [Tr-channel4]
-155750.71 -0.00054016 0.0066925 0.0017426 0.049998 0 0 0 0
-155749.23 -0.00053864 0.0066956 0.0017456 0.049998 0 0 0 0
-155749.19 -0.00054016 0.006694 0.0017456 0.049998 0 0 0 0
-155749.16 -0.00054016 0.006694 0.0017426 0.049998 0 0 0 0
-155749.15 -0.00054779 0.006694 0.0017395 0.049998 0 0 0 0
-155749.15 -0.00054626 0.006694 0.0017395 0.049998 0 0 0 0
-155749.15 -0.00054626 0.0066956 0.001741 0.049998 0 0 0 0
-155749.14 -0.00054474 0.006694 0.0017426 0.049998 0 0 0 0
-155749.14 -0.00054779 0.006694 0.0017456 0.049998 0 0 0 0
-155749.14 -0.00053864 0.006694 0.0017456 0.049998 0 0 0 0
-155749.13 -0.00053711 0.0066925 0.0017471 0.049998 0 0 0 0
-155749.13 -0.00054016 0.0066895 0.001741 0.049998 0 0 0 0
-155749.13 -0.00054932 0.006694 0.0017395 0.049998 0 0 0 0
-155749.12 -0.00054474 0.006694 0.0017426 0.049998 0 0 0 0
-155749.12 -0.00053406 0.0066925 0.0017502 0.049998 0 0 0 0
-155749.12 -0.00053711 0.0066956 0.0017487 0.049998 0 0 0 0
-155749.12 -0.00054016 0.0066925 0.0017471 0.049998 0 0 0 0
-155749.12 -0.00054321 0.006694 0.0017441 0.049998 0 0 0 0
-155749.11 -0.00053711 0.006694 0.0017471 0.049998 0 0 0 0
-155749.11 -0.00054016 0.006694 0.0017502 0.049998 0 0 0 0
-155749.11 -0.00053864 0.0066895 0.0017426 0.049998 0 0 0 0
-155749.11 -0.00054169 0.006694 0.0017395 0.049998 0 0 0 0
-155749.1 -0.00054626 0.0066956 0.0017441 0.049998 0 0 0 0
-155749.1 -0.00054474 0.006694 0.0017487 0.049998 0 0 0 0
-155749.1 -0.00056 0.0066925 0.0017456 0.049998 0 0 0 0
-155749.1 -0.00055389 0.0066956 0.0017426 0.049998 0 0 0 0
-155749.01 -0.00054626 0.0066925 0.001741 0.049998 0 0 0 0
-155749 -0.00054474 0.0066895 0.0017426 0.049998 0 0 0 0
-155749 -0.00053711 0.006694 0.0017456 0.049998 0 0 0 0
-155749 -0.00052643 0.0066925 0.0017502 0.049998 0 0 0 0
-155749 -0.00053253 0.0066925 0.0017502 0.049998 0 0 0 0
-155748.99 -0.00053406 0.006694 0.0017471 0.049998 0 0 0 0
-155748.99 -0.00053711 0.0066925 0.0017517 0.049998 0 0 0 0
-155748.99 -0.00054169 0.0066956 0.0017532 0.049998 0 0 0 0
-155748.99 -0.00053864 0.006694 0.0017532 0.049998 0 0 0 0
-155748.98 -0.00053711 0.006694 0.0017471 0.049998 0 0 0 0
-155748.98 -0.00052795 0.006694 0.0017532 0.049998 0 0 0 0
-155748.98 -0.00052338 0.006694 0.0017532 0.049998 0 0 0 0
-155748.98 -0.00053558 0.0066925 0.0017502 0.049998 0 0 0 0
-155748.97 -0.00054779 0.0066925 0.0017441 0.049998 0 0 0 0
-155748.97 -0.00054779 0.0066956 0.0017456 0.049998 0 0 0 0
-155748.97 -0.00055084 0.0066925 0.001741 0.049998 0 0 0 0
-155748.97 -0.00054932 0.006694 0.0017441 0.049998 0 0 0 0
-155748.97 -0.00055084 0.006694 0.0017502 0.049998 0 0 0 0
-155748.96 -0.00055389 0.006694 0.0017532 0.049998 0 0 0 0
-155748.96 -0.00055237 0.0066925 0.0017517 0.049998 0 0 0 0
-155748.96 -0.00053558 0.0066971 0.0017532 0.049998 0 0 0 0
-155748.96 -0.00053101 0.0066971 0.0017441 0.049998 0 0 0 0
-155748.95 -0.00053864 0.0066956 0.0017349 0.049998 0 0 0 0
-155748.93 -0.00054474 0.006694 0.001738 0.049998 0 0 0 0
-155748.92 -0.00054626 0.006694 0.0017426 0.049998 0 0 0 0
-155748.92 -0.00053558 0.006694 0.0017456 0.049998 0 0 0 0
-155748.92 -0.00052795 0.0066956 0.0017517 0.049998 0 0 0 0
-155748.92 -0.00054169 0.0066971 0.0017365 0.049998 0 0 0 0
-155748.92 -0.00054779 0.0066956 0.0017319 0.049998 0 0 0 0
-155748.92 -0.00053864 0.0066971 0.0017365 0.049998 0 0 0 0
-155748.91 -0.00054016 0.0066956 0.0017441 0.049998 0 0 0 0
-155748.91 -0.00054016 0.0066956 0.0017487 0.049998 0 0 0 0
-155748.91 -0.00054932 0.0066956 0.0017441 0.049998 0 0 0 0
-155748.91 -0.00054474 0.006694 0.0017395 0.049998 0 0 0 0
-155748.91 -0.00054016 0.0066956 0.0017365 0.049998 0 0 0 0
-155748.88 -0.00054626 0.0066971 0.0017349 0.049998 0 0 0 0
-155748.88 -0.00055237 0.0066971 0.0017288 0.049998 0 0 0 0
-155748.88 -0.00055847 0.0066971 0.0017303 0.049998 0 0 0 0
-155748.87 -0.00055237 0.0066956 0.0017303 0.049998 0 0 0 0
-155748.87 -0.00054474 0.0066925 0.001738 0.049998 0 0 0 0
-155748.87 -0.00053558 0.0066971 0.001741 0.049998 0 0 0 0
-155748.87 -0.00053711 0.0066956 0.001741 0.049998 0 0 0 0
-155748.86 -0.00054169 0.0066971 0.0017365 0.049998 0 0 0 0
-155748.86 -0.00054626 0.0066971 0.0017319 0.049998 0 0 0 0
-155748.86 -0.00054626 0.0066971 0.0017319 0.049998 0 0 0 0
-155748.86 -0.00054626 0.006694 0.0017349 0.049998 0 0 0 0
-155748.86 -0.00054321 0.0066971 0.0017349 0.049998 0 0 0 0
-155748.85 -0.00053711 0.0066956 0.001738 0.049998 0 0 0 0
-155748.85 -0.00053558 0.0066956 0.0017395 0.049998 0 0 0 0
-155748.85 -0.00054016 0.0066986 0.001741 0.049998 0 0 0 0
-155748.85 -0.00054169 0.0066971 0.001738 0.049998 0 0 0 0
-155748.84 -0.00054321 0.0066971 0.001741 0.049998 0 0 0 0
-155748.84 -0.00054169 0.0066971 0.001738 0.049998 0 0 0 0
-155748.84 -0.00053711 0.0066971 0.0017441 0.049998 0 0 0 0
-155748.84 -0.00053864 0.0066986 0.0017456 0.049998 0 0 0 0
-155748.83 -0.00054016 0.0066971 0.0017426 0.049998 0 0 0 0
-155748.83 -0.00053558 0.0066971 0.0017426 0.049998 0 0 0 0
-155748.83 -0.00053711 0.0067001 0.0017441 0.049998 0 0 0 0
-155748.83 -0.00053711 0.0066986 0.001738 0.049998 0 0 0 0
-155748.83 -0.00053711 0.0066956 0.001741 0.049998 0 0 0 0
-155748.82 -0.00053864 0.0066971 0.0017426 0.049998 0 0 0 0
-155748.82 -0.00054016 0.0066986 0.0017395 0.049998 0 0 0 0
-155748.82 -0.00053711 0.0067001 0.0017426 0.049998 0 0 0 0
-155748.82 -0.00053711 0.0067017 0.0017426 0.049998 0 0 0 0
-155748.81 -0.00053253 0.0067001 0.0017441 0.049998 0 0 0 0
-155748.81 -0.00053558 0.0066986 0.0017441 0.049998 0 0 0 0
-155748.81 -0.00052795 0.0067001 0.001738 0.049998 0 0 0 0
-155748.81 -0.0005249 0.0066986 0.001738 0.049998 0 0 0 0
-155748.8 -0.00052643 0.0066986 0.0017426 0.049998 0 0 0 0
-155748.8 -0.00053253 0.0066986 0.0017456 0.049998 0 0 0 0
-155748.8 -0.00053558 0.0067001 0.0017487 0.049998 0 0 0 0
-155748.8 -0.00053711 0.0066986 0.0017471 0.049998 0 0 0 0
-155748.8 -0.00053711 0.0066986 0.0017426 0.049998 0 0 0 0
-155748.79 -0.00053558 0.0067001 0.0017456 0.049998 0 0 0 0
-155748.79 -0.00053406 0.0067001 0.0017441 0.049998 0 0 0 0
-155748.79 -0.00053406 0.0067017 0.0017395 0.049998 0 0 0 0
-155748.78 -0.00053406 0.0067017 0.0017426 0.049998 0 0 0 0
-155748.78 -0.00053406 0.0067017 0.0017426 0.049998 0 0 0 0
-155748.78 -0.00053558 0.0067017 0.0017441 0.049998 0 0 0 0
-155748.78 -0.00053101 0.0067001 0.0017426 0.049998 0 0 0 0
-155748.78 -0.00053558 0.0067017 0.0017441 0.049998 0 0 0 0
-155748.77 -0.00053101 0.0067017 0.0017441 0.049998 0 0 0 0
-155748.77 -0.00052643 0.0067017 0.0017487 0.049998 0 0 0 0
-155748.77 -0.00052643 0.0067032 0.0017456 0.049998 0 0 0 0
-155748.77 -0.00053253 0.0067001 0.001741 0.049998 0 0 0 0
-155747.77 -0.00053711 0.0067047 0.001741 0.049998 0 0 0 0
Routine visu_exp with condition 4
Time [Val- channel1] [Val- channel2] [Val- channel3] [Val- channel4] [Tr-channel1] [Tr-channel2] [Tr-channel3] [Tr-channel4]
-199064.97 -0.00054016 0.0066925 0.0017426 0.049998 0 0 0 0
-199063.48 -0.00053864 0.0066956 0.0017456 0.049998 0 0 0 0
-199063.44 -0.00054016 0.006694 0.0017456 0.049998 0 0 0 0
-199063.41 -0.00054016 0.006694 0.0017426 0.049998 0 0 0 0
-199063.41 -0.00054779 0.006694 0.0017395 0.049998 0 0 0 0
-199063.41 -0.00054626 0.006694 0.0017395 0.049998 0 0 0 0
-199063.4 -0.00054626 0.0066956 0.001741 0.049998 0 0 0 0
-199063.4 -0.00054474 0.006694 0.0017426 0.049998 0 0 0 0
-199063.4 -0.00054779 0.006694 0.0017456 0.049998 0 0 0 0
-199063.39 -0.00053864 0.006694 0.0017456 0.049998 0 0 0 0
-199063.39 -0.00053711 0.0066925 0.0017471 0.049998 0 0 0 0
-199063.39 -0.00054016 0.0066895 0.001741 0.049998 0 0 0 0
-199063.39 -0.00054932 0.006694 0.0017395 0.049998 0 0 0 0
-199063.38 -0.00054474 0.006694 0.0017426 0.049998 0 0 0 0
-199063.38 -0.00053406 0.0066925 0.0017502 0.049998 0 0 0 0
-199063.38 -0.00053711 0.0066956 0.0017487 0.049998 0 0 0 0
-199063.38 -0.00054016 0.0066925 0.0017471 0.049998 0 0 0 0
-199063.37 -0.00054321 0.006694 0.0017441 0.049998 0 0 0 0
-199063.37 -0.00053711 0.006694 0.0017471 0.049998 0 0 0 0
-199063.37 -0.00054016 0.006694 0.0017502 0.049998 0 0 0 0
-199063.37 -0.00053864 0.0066895 0.0017426 0.049998 0 0 0 0
-199063.36 -0.00054169 0.006694 0.0017395 0.049998 0 0 0 0
-199063.36 -0.00054626 0.0066956 0.0017441 0.049998 0 0 0 0
-199063.36 -0.00054474 0.006694 0.0017487 0.049998 0 0 0 0
-199063.36 -0.00056 0.0066925 0.0017456 0.049998 0 0 0 0
-199063.35 -0.00055389 0.0066956 0.0017426 0.049998 0 0 0 0
-199063.26 -0.00054626 0.0066925 0.001741 0.049998 0 0 0 0
-199063.26 -0.00054474 0.0066895 0.0017426 0.049998 0 0 0 0
-199063.26 -0.00053711 0.006694 0.0017456 0.049998 0 0 0 0
-199063.26 -0.00052643 0.0066925 0.0017502 0.049998 0 0 0 0
-199063.25 -0.00053253 0.0066925 0.0017502 0.049998 0 0 0 0
-199063.25 -0.00053406 0.006694 0.0017471 0.049998 0 0 0 0
-199063.25 -0.00053711 0.0066925 0.0017517 0.049998 0 0 0 0
-199063.25 -0.00054169 0.0066956 0.0017532 0.049998 0 0 0 0
-199063.24 -0.00053864 0.006694 0.0017532 0.049998 0 0 0 0
-199063.24 -0.00053711 0.006694 0.0017471 0.049998 0 0 0 0
-199063.24 -0.00052795 0.006694 0.0017532 0.049998 0 0 0 0
-199063.24 -0.00052338 0.006694 0.0017532 0.049998 0 0 0 0
-199063.23 -0.00053558 0.0066925 0.0017502 0.049998 0 0 0 0
-199063.23 -0.00054779 0.0066925 0.0017441 0.049998 0 0 0 0
-199063.23 -0.00054779 0.0066956 0.0017456 0.049998 0 0 0 0
-199063.23 -0.00055084 0.0066925 0.001741 0.049998 0 0 0 0
-199063.22 -0.00054932 0.006694 0.0017441 0.049998 0 0 0 0
-199063.22 -0.00055084 0.006694 0.0017502 0.049998 0 0 0 0
-199063.22 -0.00055389 0.006694 0.0017532 0.049998 0 0 0 0
-199063.22 -0.00055237 0.0066925 0.0017517 0.049998 0 0 0 0
-199063.22 -0.00053558 0.0066971 0.0017532 0.049998 0 0 0 0
-199063.21 -0.00053101 0.0066971 0.0017441 0.049998 0 0 0 0
-199063.21 -0.00053864 0.0066956 0.0017349 0.049998 0 0 0 0
-199063.18 -0.00054474 0.006694 0.001738 0.049998 0 0 0 0
-199063.18 -0.00054626 0.006694 0.0017426 0.049998 0 0 0 0
-199063.18 -0.00053558 0.006694 0.0017456 0.049998 0 0 0 0
-199063.18 -0.00052795 0.0066956 0.0017517 0.049998 0 0 0 0
-199063.18 -0.00054169 0.0066971 0.0017365 0.049998 0 0 0 0
-199063.17 -0.00054779 0.0066956 0.0017319 0.049998 0 0 0 0
-199063.17 -0.00053864 0.0066971 0.0017365 0.049998 0 0 0 0
-199063.17 -0.00054016 0.0066956 0.0017441 0.049998 0 0 0 0
-199063.17 -0.00054016 0.0066956 0.0017487 0.049998 0 0 0 0
-199063.17 -0.00054932 0.0066956 0.0017441 0.049998 0 0 0 0
-199063.17 -0.00054474 0.006694 0.0017395 0.049998 0 0 0 0
-199063.16 -0.00054016 0.0066956 0.0017365 0.049998 0 0 0 0
-199063.14 -0.00054626 0.0066971 0.0017349 0.049998 0 0 0 0
-199063.13 -0.00055237 0.0066971 0.0017288 0.049998 0 0 0 0
-199063.13 -0.00055847 0.0066971 0.0017303 0.049998 0 0 0 0
-199063.13 -0.00055237 0.0066956 0.0017303 0.049998 0 0 0 0
-199063.13 -0.00054474 0.0066925 0.001738 0.049998 0 0 0 0
-199063.13 -0.00053558 0.0066971 0.001741 0.049998 0 0 0 0
-199063.12 -0.00053711 0.0066956 0.001741 0.049998 0 0 0 0
-199063.12 -0.00054169 0.0066971 0.0017365 0.049998 0 0 0 0
-199063.12 -0.00054626 0.0066971 0.0017319 0.049998 0 0 0 0
-199063.12 -0.00054626 0.0066971 0.0017319 0.049998 0 0 0 0
-199063.11 -0.00054626 0.006694 0.0017349 0.049998 0 0 0 0
-199063.11 -0.00054321 0.0066971 0.0017349 0.049998 0 0 0 0
-199063.11 -0.00053711 0.0066956 0.001738 0.049998 0 0 0 0
-199063.11 -0.00053558 0.0066956 0.0017395 0.049998 0 0 0 0
-199063.11 -0.00054016 0.0066986 0.001741 0.049998 0 0 0 0
-199063.1 -0.00054169 0.0066971 0.001738 0.049998 0 0 0 0
-199063.1 -0.00054321 0.0066971 0.001741 0.049998 0 0 0 0
6 Comments
MANISH SINGH
on 22 Jul 2023
Moved: Voss
on 22 Jul 2023
I have a simillar doubt but the data set is bit different. I want to create multiple plots form the given data set
(title "Static Temperature")
(labels "Position" "Static Temperature")
((xy/key/label "t2")
2.70126e-18 1620.92
0.00025 1620.95
0.000521687 1621.06
0.00081651 1621.27
0.00113593 1621.59
0.00148141 1622.07
0.00185437 1622.71
0.00225619 1623.56
0.00268817 1624.65
0.0031515 1626.01
0.00364721 1627.67
0.00417614 1629.67
0.00473892 1632.03
0.00533589 1634.8
0.00596711 1637.98
0.00663228 1641.61
0.00733071 1645.68
0.00806131 1650.2
0.00882256 1655.16
0.0096125 1656.88
0.0104287 1653.46
0.0112685 1648.14
0.0121284 1642.2
0.013005 1635.65
0.0138945 1628.51
0.0147925 1620.81
0.015695 1612.58
0.0165975 1603.63
0.0174955 1594.04
0.018385 1584.14
0.0192616 1574.03
0.0201215 1563.8
0.0209613 1553.52
0.0217775 1543.19
0.0225674 1532.9
0.0233287 1522.77
0.0240593 1512.88
0.0247577 1503.26
0.0254229 1493.94
0.0260541 1484.92
0.0266511 1476.16
0.0272139 1467.72
0.0277428 1459.65
0.0282385 1451.92
0.0287018 1444.54
0.0291338 1437.49
0.0295356 1430.77
0.0299086 1424.36
0.0302541 1418.17
0.0305735 1412.19
0.0308683 1406.51
0.03114 1401.15
0.03139 1396.12
0.03157 1392.43
0.03182 1387.23
0.032089 1381.51
0.0323776 1375.23
0.0326864 1368.34
0.0330157 1360.78
0.0333659 1352.37
0.033737 1342.98
0.0341287 1332.71
0.0345406 1321.6
0.0349719 1309.63
0.0354217 1296.78
0.0358887 1282.84
0.0363713 1267.79
0.0368677 1251.93
0.0373757 1235.43
0.037893 1218.17
0.038417 1200.21
0.0389452 1181.88
0.0394748 1163.4
0.040003 1144.64
0.040527 1125.8
0.0410443 1107.23
0.0415523 1088.83
0.0420486 1070.66
0.0425312 1053.06
0.0429983 1035.99
0.0434481 1019.26
0.0438794 1003.06
0.0442913 987.676
0.044683 972.876
0.0450541 958.711
0.0454043 945.29
0.0457336 932.556
0.0460424 920.746
0.046331 910.447
0.0466 901.437
0.04685 893.106
0.0471 884.793
0.0473625 876.08
0.0476381 866.851
0.0479275 856.999
0.0482314 846.937
0.0485505 836.771
0.0488855 826.214
0.0492373 815.181
0.0496066 803.03
0.0499945 790.123
0.0504017 777.142
0.0508293 764.401
0.0512782 752.911
0.0517497 744.036
0.0522446 739.378
0.0527462 738.342
0.0532477 738.604
0.0537492 739.041
0.0542508 739.356
0.0547523 739.447
0.0552538 739.191
0.0557554 738.498
0.0562503 737.424
0.0567218 736.14
0.0571707 734.709
0.0575983 733.223
0.0580055 731.796
0.0583934 730.407
0.0587627 728.776
0.0591145 726.579
0.0594495 723.803
0.0597686 720.389
0.0600725 714.914
0.0603619 697.279
0.0606375 659.795
0.0609 593.071
0.06115 500
)
((xy/key/label "t3")
0.03157 2008.75
0.03182 2011.5
0.032089 2014.45
0.0323776 2017.59
0.0326864 2020.9
0.0330157 2023.98
0.0333659 2026.73
0.033737 2029.47
0.0341287 2032.22
0.0345406 2034.95
0.0349719 2037.58
0.0354217 2039.48
0.0358887 2040.51
0.0363714 2041.18
0.0368677 2041.43
0.0373757 2040.82
0.037893 2038.9
0.038417 2035.69
0.0389452 2030.99
0.0394748 2024.56
0.040003 2016.41
0.040527 2006.17
0.0410443 1993.57
0.0415523 1978.97
0.0420486 1962.81
0.0425312 1945.26
0.0429983 1927.56
0.0434481 1910.48
0.0438794 1892.89
0.0442913 1874.3
0.044683 1856.9
0.0450541 1842.2
0.0454043 1828.86
0.0457336 1817.12
0.0460424 1807.2
0.046331 1798.01
0.0466 1789.47
0.04685 1782.35
0.0471 1775.96
0.0473625 1769.21
0.0476381 1762.07
0.0479275 1754.52
0.0482314 1746.57
0.0485505 1738.18
0.0488855 1729.34
0.0492373 1720.43
0.0496066 1711.52
0.0499945 1702.26
0.0504017 1692.62
0.0508293 1682.57
0.0512782 1672.04
0.0517497 1660.72
0.0522446 1647.56
0.0527462 1631.94
0.0532477 1614.37
0.0537492 1595.76
0.0542508 1576.63
0.0547523 1556.99
0.0552538 1534.99
0.0557554 1510.16
0.0562503 1484.17
0.0567218 1457.83
0.0571707 1430.67
0.0575983 1402.29
0.0580055 1371.35
0.0583934 1337.82
0.0587627 1301.92
0.0591145 1261.73
0.0594495 1210.74
0.0597686 1146.01
0.0600725 1069.41
0.0603619 976.572
0.0606375 855.951
0.0609 694.22
0.06115 500
2.29829e-18 1693.92
0.00025 1693.95
0.000521687 1694.06
0.00081651 1694.26
0.00113593 1694.57
0.00148141 1695.02
0.00185437 1695.64
0.00225619 1696.46
0.00268817 1697.49
0.0031515 1698.79
0.00364721 1700.37
0.00417614 1702.26
0.00473892 1704.51
0.00533589 1707.17
0.00596711 1710.29
0.00663228 1713.91
0.00733071 1718.05
0.00806131 1722.75
0.00882256 1728.03
0.0096125 1733.91
0.0104287 1740.38
0.0112685 1747.46
0.0121284 1755.12
0.013005 1763.34
0.0138945 1772.11
0.0147925 1782.4
0.015695 1794.2
0.0165975 1806.34
0.0174955 1818.61
0.018385 1830.92
0.0192616 1843.19
0.0201215 1855.32
0.0209613 1867.23
0.0217775 1878.87
0.0225674 1890.15
0.0233287 1901.05
0.0240593 1911.5
0.0247577 1921.5
0.0254229 1931
0.0260541 1940.01
0.0266511 1948.5
0.0272139 1956.19
0.0277428 1963.04
0.0282385 1969.29
0.0287018 1975.02
0.0291338 1980.3
0.0295356 1985.17
0.0299086 1989.64
0.0302541 1993.72
0.0305735 1997.44
0.0308683 2000.84
0.03114 2003.93
0.03139 2006.74
0.03157 2008.75
)
((xy/key/label "t4")
2.20677e-18 1720.49
0.00025 1720.52
0.000521687 1720.62
0.00081651 1720.81
0.00113593 1721.11
0.00148141 1721.54
0.00185437 1722.14
0.00225619 1722.92
0.00268818 1723.92
0.0031515 1725.17
0.00364721 1726.71
0.00417614 1728.58
0.00473892 1730.79
0.00533589 1733.35
0.00596712 1736.32
0.00663228 1739.75
0.00733071 1743.69
0.00806131 1748.15
0.00882256 1753.16
0.0096125 1758.82
0.0104287 1766.19
0.0112685 1775.3
0.0121284 1785.13
0.013005 1795.57
0.0138945 1806.57
0.0147925 1818.04
0.015695 1829.74
0.0165975 1841.48
0.0174955 1853.31
0.018385 1865.22
0.0192616 1877.12
0.0201215 1888.93
0.0209613 1900.56
0.0217775 1911.94
0.0225674 1922.99
0.0233287 1933.67
0.0240593 1943.93
0.0247577 1953.77
0.0254229 1963.21
0.0260541 1972.12
0.0266511 1980.36
0.0272139 1987.93
0.0277428 1994.88
0.0282385 2001.12
0.0287018 2006.64
0.0291338 2011.59
0.0295356 2016.1
0.0299086 2020.2
0.0302541 2023.94
0.0305735 2027.34
0.0308683 2030.16
0.03114 2032.42
0.03139 2034.4
0.03157 2035.79
0.03182 2037.67
0.032089 2039.62
0.0323776 2041.65
0.0326864 2043.76
0.0330157 2045.9
0.0333659 2047.81
0.033737 2049.19
0.0341287 2050.19
0.0345406 2051
0.0349719 2051.55
0.0354217 2051.81
0.0358887 2051.38
0.0363714 2049.86
0.0368677 2047.45
0.0373757 2044.07
0.037893 2039.42
0.038417 2033.44
0.0389452 2026.09
0.0394748 2017.35
0.040003 2006.93
0.040527 1994.83
0.0410443 1981.31
0.0415523 1966.77
0.0420486 1951.36
0.0425313 1935.57
0.0429983 1920.56
0.0434481 1905.75
0.0438794 1890.35
0.0442913 1874.7
0.044683 1860.44
0.0450541 1848.85
0.0454043 1838.65
0.0457336 1828.96
0.0460424 1820.8
0.046331 1814.02
0.0466 1807.62
0.04685 1801.59
0.0471 1795.86
0.0473625 1790.61
0.0476381 1785.54
0.0479275 1780.18
0.0482314 1774.51
0.0485505 1768.51
0.0488855 1762.14
0.0492373 1755.38
0.0496066 1748.18
0.0499945 1740.83
0.0504017 1733.4
0.0508293 1725.49
0.0512782 1716.98
0.0517497 1707.61
0.0522446 1696.89
0.0527462 1684.8
0.0532477 1670.46
0.0537492 1654
0.0542508 1636.51
0.0547523 1618
0.0552538 1598.46
0.0557554 1576.36
0.0562503 1550.73
0.0567218 1523.47
0.0571707 1495.02
0.0575983 1464.83
0.0580055 1434.15
0.0583934 1402.42
0.0587627 1361.42
0.0591145 1308.68
0.0594495 1247.82
0.0597686 1178.94
0.0600725 1099.06
0.0603619 1001.28
0.0606375 873.79
0.0609 703.516
0.06115 500
)
((xy/key/label "temp_1")
2.79456e-18 1409.24
0.00025 1409.28
0.000521687 1409.41
0.00081651 1409.65
0.00113593 1410.04
0.00148141 1410.59
0.00185437 1411.35
0.00225619 1412.35
0.00268817 1413.62
0.0031515 1415.21
0.00364721 1417.18
0.00417614 1419.55
0.00473892 1422.4
0.00533589 1425.77
0.00596712 1429.72
0.00663228 1434.31
0.00733071 1439.59
0.00806131 1445.6
0.00882256 1452.37
0.0096125 1459.97
0.0104287 1467.69
0.0112685 1473.5
0.0121284 1477.68
0.013005 1481.78
0.0138945 1485.74
0.0147925 1489.54
0.015695 1493.15
0.0165975 1496.56
0.0174955 1499.76
0.018385 1502.28
0.0192616 1499.21
0.0201215 1490.39
0.0209613 1480.58
0.0217775 1470.4
0.0225674 1459.99
0.0233287 1449.47
0.0240593 1439.01
0.0247577 1428.65
0.0254229 1418.39
0.0260541 1408.22
0.0266511 1398.1
0.0272139 1388.07
0.0277428 1378.2
0.0282385 1368.4
0.0287018 1358.45
0.0291338 1348.45
0.0295356 1338.65
0.0299086 1329.16
0.0302541 1319.98
0.0305735 1311.05
0.0308683 1302.38
0.03114 1294
0.03139 1285.92
0.03157 1279.86
0.03182 1271.16
0.032089 1261.4
0.0323776 1250.43
0.0326864 1238.15
0.0330157 1224.32
0.0333659 1208.66
0.033737 1191.14
0.0341287 1171.78
0.0345406 1150.14
0.0349719 1126.2
0.0354217 1100.2
0.0358887 1072.12
0.0363714 1042.25
0.0368677 1010.98
0.0373757 978.727
0.037893 946.001
0.038417 913.45
0.0389452 881.526
0.0394748 850.755
0.040003 821.604
0.040527 794.452
0.0410443 770.194
0.0415523 749.08
0.0420486 730.881
0.0425312 715.755
0.0429983 703.969
0.0434481 696.163
0.0512782 744.882
0.0508293 746.187
0.0517497 742.857
0.0522446 740.033
0.0527462 736.71
0.0532477 733.287
0.0537492 730.042
0.0542508 727.125
0.0547523 724.591
0.0552538 722.44
0.0557554 720.622
0.0562503 719.093
0.0567218 717.814
0.0571707 716.697
0.0575983 715.677
0.0580055 714.705
0.0583934 713.739
0.0587627 712.743
0.0591145 711.619
0.0594495 709.956
0.0597686 707.057
0.0600725 701.921
0.0603619 691.598
0.0606375 665.64
0.0609 602.709
0.06115 500
0.0434481 696.163
0.0438794 692.435
0.0442913 691.965
0.044683 693.601
0.0450541 696.649
0.0454043 700.858
0.0457336 706.016
0.0460424 711.971
0.046331 718.238
0.0466 723.931
0.04685 728.509
0.0471 732.253
0.0473625 735.445
0.0476381 738.231
0.0479275 740.68
0.0482314 742.773
0.0485505 744.457
0.0488855 745.707
0.0492373 746.543
0.0496066 747.01
0.0499945 747.135
0.0504017 746.899
0.0508293 746.187
)
Accepted Answer
Adam Danz
on 30 Jul 2019
Edited: Adam Danz
on 2 Aug 2019
The code below will read the txt file attached, psychData.txt (data copied from your question).
The first section uses fgetl() which very quickly scans your entire file line by line and merely stores the line numbers where a routine starts ("routineLine"). The next section creates a table for each routine in a loop. It uses textscan() to pull the routine name and stores it in "R". It then uses readmatrix() along with delimitedTextImportOptions() to pull the matrix data from each routine. The tables are stored in the cell array "T". If there are small differences between the attached txt file and your real data, you may need to tweek some of the settings in delimitedTextImportOptions(). See my text after the code for examples of how to work with the data.
%% FIND ROUTINE LINES
filename = 'psychData.txt'; %full path would be better
fid = fopen(filename); %opens file
c = 1; %line counter
routineLine = []; %stores line numbers of Routine
tline = fgetl(fid); %reads 1st line
while ischar(tline) %loop through each line
if regexp(tline,'^Routine')==1 %Determine if line begins with "Routine"
routineLine(end+1) = c; %store line number of "Routine" lines
end
tline = fgetl(fid); %reads next line
c = c+1; %increment line counter
end
%% PUT MATRIX DATA INTO TABLES
% set up option for reading the matrix data (see delimitedTextImportOptions for help)
varNames = {'Time','ch1','ch2','ch3','ch4','trCh1','trCh2','trCh3','trCh4'};
opts = delimitedTextImportOptions('NumVariables',numel(varNames), 'VariableTypes',repelem({'double'},1,9), ...
'Delimiter','\t','ConsecutiveDelimitersRule','join','ExtraColumnsRule','ignore');
T = cell(numel(routineLine),1); % will store tables
R = T; % will store routine names
routineLine = [routineLine, c-1]; % add last line of text to routineLine
% loop through each routine and extract name and matrix
for i = 1:numel(routineLine)-1
frewind(fid) % Reset to 1st row
routineTxt = textscan(fid,'%s',1,'delimiter','\n','headerlines',routineLine(i)-1); %routine text
R{i} = routineTxt{1}{1}; % store routine name
% The matrix will be 2 lines after the routine line and will end 2 line prior to next routine or end of file.
opts.DataLines = [routineLine(i)+2, routineLine(i+1)-2];
matData = readmatrix(filename,opts);
% store in table
T{i} = array2table(matData,'VariableNames',varNames);
T{i}.Properties.Description = R{i};
end
fclose(fid); %close file
How to work with the data
n = 2;
T{n} % is table number 2
R{n} % is the routine name
% The routine name is also stored in the table
T{n}.Properties.Description % routine name
2 Comments
More Answers (0)
See Also
Categories
Find more on Large Files and Big Data 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!