import text file with delimter

1 visualización (últimos 30 días)
Avi
Avi el 28 de En. de 2018
Respondida: Walter Roberson el 28 de En. de 2018
Dear Users,
Below are the few lines of the text (Raw.txt) which should have three columns of data.
  • Column 1: index (e.g.20121128,)
  • Column 2: clock_tick (e.g. 12:51:16.812:)
  • Column 3: comments (e.g. Click detected at (0, -2) from the center of target 45. Absolute position: (880, 553) out)
The problem is when I use textscan or importdata, with delimiter. The imported file assumes there is either 2 columns (col, col&3combined), or 3 to 5 columns (based on the position of the comma)
For example the following row would be passed as 5 columns
20121115, 15:00:31.796: Click detected at (0, 0) from the center of target 13. Absolute position: (880, 249) out of (1280, 918).
Raw.txt
20121115, 14:57:48.343: Session starting. Session parameters to follow.
20121115, 14:57:48.343: Subject ID: 101
20121115, 14:57:48.343: Session Number: 1
20121115, 14:57:48.343: Run Number: 1
20121115, 14:57:48.343: # Rows: 6
20121115, 14:57:48.343: # Columns: 8
20121115, 14:57:48.343: Time Between Trials (s): 3
20121115, 14:57:48.343: Clip top (pixels): 20
20121115, 14:57:48.343: Clip bottom (pixels): 65
20121115, 14:57:48.343: # Trials: 5
20121115, 14:57:51.406: Target 10 appeared.
20121115, 15:00:31.796: Click detected at (0, 0) from the center of target 13. Absolute position: (880, 249) out of (1280, 918).
  1 comentario
Image Analyst
Image Analyst el 28 de En. de 2018
You forgot to attach raw.txt, so we can't try anything, yet. After you read this and fix your formatting, and post your file, I'll check again.

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 28 de En. de 2018
Use a textscan format of '%f,%{HH:mm:ss.SSS:}D%[^\n]'

Community Treasure Hunt

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

Start Hunting!

Translated by